feat(mobile): distinguish app identities by build profile
This commit is contained in:
3 files changed
+65
No files matched your search
@@ -0,0 +1,25 @@
|
|||||||
|
# Mobile build variants
|
||||||
|
|
||||||
|
EAS profiles set `APP_VARIANT` to select the app identity in `app.config.ts`.
|
||||||
|
Both iOS bundle identifiers and Android package names use these values:
|
||||||
|
|
||||||
|
| Profile | App name | Identifier |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| development | oTunes (Development) | com.abunchofknowitalls.otunes.development |
|
||||||
|
| preview | oTunes (Preview) | com.abunchofknowitalls.otunes.preview |
|
||||||
|
| production | oTunes | com.abunchofknowitalls.otunes |
|
||||||
|
|
||||||
|
Build with `eas build --profile development`, `--profile preview`, or
|
||||||
|
`--profile production` from this directory.
|
||||||
|
|
||||||
|
For local builds and Metro, select the same variant explicitly:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
APP_VARIANT=development pnpm ios
|
||||||
|
APP_VARIANT=development pnpm android
|
||||||
|
APP_VARIANT=development pnpm start
|
||||||
|
```
|
||||||
|
|
||||||
|
An unset `APP_VARIANT` keeps the production identity. Unknown variants fail
|
||||||
|
configuration. URL schemes are `otunes-development`, `otunes-preview`, and
|
||||||
|
`otunes` respectively, allowing the apps to be installed together.
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
import type { ConfigContext, ExpoConfig } from "expo/config"
|
||||||
|
|
||||||
|
export default ({ config }: ConfigContext): ExpoConfig => {
|
||||||
|
const variant = process.env.APP_VARIANT ?? "production"
|
||||||
|
if (!["development", "preview", "production"].includes(variant)) {
|
||||||
|
throw new Error(`Unsupported APP_VARIANT: ${variant}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
const suffix = variant === "production" ? "" : `.${variant}`
|
||||||
|
const nameSuffix =
|
||||||
|
variant === "development"
|
||||||
|
? " (Development)"
|
||||||
|
: variant === "preview"
|
||||||
|
? " (Preview)"
|
||||||
|
: ""
|
||||||
|
|
||||||
|
return {
|
||||||
|
...config,
|
||||||
|
name: `${config.name}${nameSuffix}`,
|
||||||
|
slug: config.slug!,
|
||||||
|
scheme: variant === "production" ? "otunes" : `otunes-${variant}`,
|
||||||
|
ios: {
|
||||||
|
...config.ios,
|
||||||
|
bundleIdentifier: `${config.ios!.bundleIdentifier}${suffix}`,
|
||||||
|
},
|
||||||
|
android: {
|
||||||
|
...config.android,
|
||||||
|
package: `${config.android!.package}${suffix}`,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,13 +5,22 @@
|
|||||||
},
|
},
|
||||||
"build": {
|
"build": {
|
||||||
"development": {
|
"development": {
|
||||||
|
"env": {
|
||||||
|
"APP_VARIANT": "development"
|
||||||
|
},
|
||||||
"developmentClient": true,
|
"developmentClient": true,
|
||||||
"distribution": "internal"
|
"distribution": "internal"
|
||||||
},
|
},
|
||||||
"preview": {
|
"preview": {
|
||||||
|
"env": {
|
||||||
|
"APP_VARIANT": "preview"
|
||||||
|
},
|
||||||
"distribution": "internal"
|
"distribution": "internal"
|
||||||
},
|
},
|
||||||
"production": {
|
"production": {
|
||||||
|
"env": {
|
||||||
|
"APP_VARIANT": "production"
|
||||||
|
},
|
||||||
"autoIncrement": true
|
"autoIncrement": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in new issue
Block a user