配置 app.config.ts
第一步:将 app.config.ts 中的模板标识替换为你自己的应用信息
配置 app.config.ts
apps/native/app.config.ts 是 Expo 应用的核心配置文件。拿到模板后,第一步就应该把其中属于 EasyStarter 的标识信息替换成你自己的。
详细字段说明参考 Expo 官方应用配置文档
第一步:确定并创建应用标识
在修改 app.config.ts 之前,先确定你的应用标识,并在 Apple Developer Portal 完成注册。
确定标识符格式
iOS 和 Android 的标识符都推荐使用反向域名格式:
com.yourcompany.yourappiOS 的 bundleIdentifier 和 Android 的 package 建议保持一致,方便管理。
在 Apple Developer Portal 创建 App ID
iOS 的 bundleIdentifier 不是随意填写的字符串——它必须先在 Apple Developer Portal 注册为 App ID,才能用于 App Store 发布和 Apple 原生能力(如 Sign In with Apple)。
- 登录 Apple Developer Portal → Identifiers
- 点击
+新建 → 选择App IDs→ 类型选App→ Continue - 填写 Description(你的应用名)
- 填写 Bundle ID(例如
com.yourcompany.yourapp),选择Explicit - 在 Capabilities 中勾选 Sign In with Apple
- 点击 Continue → Register
注册完成后,将这个 Bundle ID 填入以下两处:
const baseConfig: ExpoConfig = {
ios: {
bundleIdentifier: "com.yourcompany.yourapp",
},
};APPLE_APP_BUNDLE_IDENTIFIER=com.yourcompany.yourappAndroid 包名
Android 不需要提前注册,你只需要在 app.config.ts 中填写一个符合格式的包名即可。在发布到 Google Play 时才需要注册。
必须替换的字段
以下字段直接影响应用身份、深链和应用商店发布,必须在开始开发之前修改:
以下字段均位于 app.config.ts 的 baseConfig 对象中。
name
应用显示名称,会出现在设备桌面和系统设置中。
name: "My App",slug
Expo 服务中的 URL 标识,全局唯一,只能包含字母、数字和连字符。
slug: "my-app",scheme
Deep link 协议头,用于 OAuth 回调和应用间跳转。建议与 slug 保持一致,避免与其他 App 冲突。
scheme: "my-app",移动端 Better Auth 的 OAuth 回调(Google 登录)依赖这个 scheme。
ios.bundleIdentifier
iOS 应用唯一标识,必须与 Apple Developer Portal 中创建的 App ID 完全一致。
ios: {
bundleIdentifier: "com.yourcompany.yourapp",
}同时也是
APPLE_APP_BUNDLE_IDENTIFIER环境变量的值。
ios.appleTeamId
你的 Apple 开发者 Team ID,在 Apple Developer Portal → Membership 页面中可以找到。
ios: {
appleTeamId: "XXXXXXXXXX",
}android.package
Android 应用包名,必须与 Google Play Console 中注册的包名一致,格式为反向域名。
android: {
package: "com.yourcompany.yourapp",
}extra.eas.projectId 和 updates.url
这两个字段用于绑定你在 EAS 上的项目。如果你直接克隆了模板,需要先运行:
cd apps/native
eas initapp.config.ts 是动态配置,EAS CLI 不会自动回写。运行完成后,将命令输出的项目 ID 手动填入 easProjectId;updates.url 会由该常量生成。
图标与启动页
以下路径指向的图片需要替换为你自己的品牌资产:
| 字段 | 路径 | 说明 |
|---|---|---|
icon | ./assets/images/icon.png | 通用图标(1024×1024 PNG) |
ios.icon.light | ./assets/images/icon.png | iOS 浅色模式图标 |
ios.icon.dark | ./assets/images/icon.png | iOS 深色模式图标 |
android.adaptiveIcon.foregroundImage | ./assets/images/android-icon-foreground.png | Android 自适应图标前景 |
android.adaptiveIcon.backgroundImage | ./assets/images/android-icon-background.png | Android 自适应图标背景 |
android.adaptiveIcon.monochromeImage | ./assets/images/android-icon-monochrome.png | Android 单色图标 |
plugins[expo-splash-screen].image | ./assets/images/icon.png | 启动屏图片 |
完整配置参考
import type { ExpoConfig } from "expo/config";
const appVersion = "1.0.0";
const easProjectId = "your-eas-project-id";
const baseConfig: ExpoConfig = {
name: "My App",
slug: "my-app",
version: appVersion,
orientation: "portrait",
icon: "./assets/images/icon.png",
scheme: "my-app",
userInterfaceStyle: "automatic",
ios: {
appleTeamId: "YOUR_TEAM_ID",
buildNumber: "1.0.0",
bundleIdentifier: "com.yourcompany.yourapp",
usesAppleSignIn: true,
icon: {
dark: "./assets/images/icon.png",
light: "./assets/images/icon.png",
},
infoPlist: {
ITSAppUsesNonExemptEncryption: false,
},
},
android: {
adaptiveIcon: {
backgroundColor: "#E6F4FE",
foregroundImage: "./assets/images/android-icon-foreground.png",
backgroundImage: "./assets/images/android-icon-background.png",
monochromeImage: "./assets/images/android-icon-monochrome.png",
},
predictiveBackGestureEnabled: false,
permissions: ["android.permission.RECORD_AUDIO"],
package: "com.yourcompany.yourapp",
},
extra: {
router: {},
eas: {
projectId: easProjectId,
},
},
updates: {
url: `https://u.expo.dev/${easProjectId}`,
},
};
export default (): ExpoConfig => ({
...baseConfig,
runtimeVersion: appVersion,
});