1---
2title: Installing app variants on the same device
3maxHeadingDepth: 4
4---
5
6import ImageSpotlight from '~/components/plugins/ImageSpotlight';
7
8When creating [development, preview, and production builds](../build/eas-json/#common-use-cases), it's common to want to install one of each build on your device at the same time.
9This allows you to do development work, preview the next version of your app, and run the production version all on the same device, without needing to uninstall and reinstall the app.
10
11In order to be able to have multiple instances of an app installed on your device, each instance must have a unique Application ID (Android) or Bundle Identifier (iOS).
12
13**If you have a managed project**, this can be accomplished by using **app.config.js** and environment variables in **eas.json**.
14
15**If you have a bare project**, you can accomplish this using flavors (Android) and targets (iOS). To configure which flavor is used, use the `gradleCommand` field on your build profile. To configure which target is used, use the `scheme` field for iOS.
16
17## Configuring development and production variants
18
19### In managed project
20
21Let's say we wanted a development build and production build of our managed Expo project. Your **eas.json** might look like this:
22
23```json eas.json
24{
25  "build": {
26    "development": {
27      "developmentClient": true
28    },
29    "production": {}
30  }
31}
32```
33
34And your **app.json** might look like this:
35
36```json app.json
37{
38  "expo": {
39    "name": "MyApp",
40    "slug": "my-app",
41    "ios": {
42      "bundleIdentifier": "com.myapp"
43    },
44    "android": {
45      "package": "com.myapp"
46    }
47  }
48}
49```
50
51Let's convert this to **app.config.js** so we can make it more dynamic:
52
53```js app.config.js
54export default {
55  name: 'MyApp',
56  slug: 'my-app',
57  ios: {
58    bundleIdentifier: 'com.myapp',
59  },
60  android: {
61    package: 'com.myapp',
62  },
63};
64```
65
66Now let's switch out the iOS `bundleIdentifier` and Android `package` (which becomes the Application ID) based on the presence of an environment variable in **app.config.js**:
67
68```js app.config.js
69const IS_DEV = process.env.APP_VARIANT === 'development';
70
71export default {
72  // You can also switch out the app icon and other properties to further
73  // differentiate the app on your device.
74  name: IS_DEV ? 'MyApp (Dev)' : 'MyApp',
75  slug: 'my-app',
76  ios: {
77    bundleIdentifier: IS_DEV ? 'com.myapp.dev' : 'com.myapp',
78  },
79  android: {
80    package: IS_DEV ? 'com.myapp.dev' : 'com.myapp',
81  },
82};
83```
84
85> **Note**: if you are using any libraries that require you to register your application identifier with an external service to use the SDK, such as Google Maps, you will need to have a separate configuration for that API for the iOS Bundle Identifier and Android Package. You can also swap this configuration in using the same approach as above.
86
87To automatically set the `APP_VARIANT` environment variable when running builds with the "development" profile, we can use `env` in **eas.json**:
88
89```json eas.json
90{
91  "build": {
92    "development": {
93      "developmentClient": true,
94      "env": {
95        "APP_VARIANT": "development"
96      }
97    },
98    "production": {}
99  }
100}
101```
102
103Now when you run `eas build --profile development`, the environment variable `APP_VARIANT` will be set to `"development"` when evaluating **app.config.js** both locally and on the EAS Build worker. When you start your development server, you will need to run `APP_VARIANT=development expo start` (or the platform equivalent if you use Windows); a shortcut for this could be to add a script to your **package.json** such as `"dev": "APP_VARIANT=development expo start"`.
104
105When you run `eas build --profile production` the `APP_VARIANT` variable environment will not be set, and the build will run as the production variant.
106
107> **Note**: if you use EAS Update to publish JavaScript updates of your app, you should be cautious to set the correct environment variables for the app variant that you are publishing for when you run the `eas update` command. Refer to the EAS Build ["Environment variables and secrets" guide](/build/updates.mdx) for more information.
108
109### In bare project
110
111#### Android
112
113In **android/app/build.gradle**, create a separate flavor for every build profile from **eas.json** that you want to build.
114
115```groovy android/app/build.gradle
116android {
117    /* @hide ... */ /* @end */
118    flavorDimensions "env"
119    productFlavors {
120        production {
121            dimension "env"
122            applicationId 'com.myapp'
123        }
124        development {
125            dimension "env"
126            applicationId 'com.myapp.dev'
127        }
128    }
129    /* @hide ... */ /* @end */
130}
131```
132
133> **Note**: Currently, EAS CLI supports only the `applicationId` field. If you use `applicationIdSuffix` inside `productFlavors` or `buildTypes` sections then this value will not be detected correctly.
134
135Assign Android flavors to EAS build profiles by specifying a `gradleCommand` in the **eas.json**:
136
137```json eas.json
138{
139  "build": {
140    "development": {
141      "android": {
142        "gradleCommand": ":app:assembleDevelopmentDebug"
143      }
144    },
145    "production": {
146      "android": {
147        "gradleCommand": ":app:bundleProductionRelease"
148      }
149    }
150  }
151}
152```
153
154By default, every flavor can be built in either debug or release mode. If you want to restrict some flavor to a specific mode, see the snippet below, and modify **build.gradle**.
155
156```groovy android/app/build.gradle
157android {
158    /* @hide ... */ /* @end */
159    variantFilter { variant ->
160        def validVariants = [
161                ["production", "release"],
162                ["development", "debug"],
163        ]
164        def buildTypeName = variant.buildType*.name
165        def flavorName = variant.flavors*.name
166
167        def isValid = validVariants.any { flavorName.contains(it[0]) && buildTypeName.contains(it[1]) }
168        if (!isValid) {
169            setIgnore(true)
170        }
171    }
172    /* @hide ... */ /* @end */
173}
174```
175
176The rest of the configuration at this point is not specific to EAS, it's the same as it would be for any Android project with flavors. There are a few common configurations that you might want to apply to your project:
177
178- To change the name of the app built with the development profile, create a **android/app/src/development/res/value/strings.xml** file.
179  ```xml
180  <resources>
181      <string name="app_name">MyApp - Dev</string>
182  </resources>
183  ```
184- To change the icon of the app built with the development profile, create `android/app/src/development/res/mipmap-*` directories with appropriate assets (you can copy them from **android/app/src/main/res** and replace the icon files).
185- To specify **google-services.json** for a specific flavor put it in a **android/app/src/&lbrace;flavor&rbrace;/google-services.json** file.
186- To configure sentry, add `project.ext.sentryCli = [ flavorAware: true ]` to **android/app/build.gradle** and name your properties file `android/sentry-{flavor}-{buildType}.properties` (e.g. **android/sentry-production-release.properties**)
187
188#### iOS
189
190Assign a distinct scheme to every build profile in **eas.json**:
191
192```json eas.json
193{
194  "build": {
195    "development": {
196      "ios": {
197        "buildConfiguration": "Debug",
198        "scheme": "myapp-dev"
199      }
200    },
201    "production": {
202      "ios": {
203        "buildConfiguration": "Release",
204        "scheme": "myapp"
205      }
206    }
207  }
208}
209```
210
211**Podfile** should have a target defined like this:
212
213```ruby Podfile
214target 'myapp' do
215  # @hide ... #
216  # @end #
217end
218```
219
220Replace it with an abstract target, where common configuration can be copied from the old target:
221
222```ruby Podfile
223abstract_target 'common' do
224  # put common target configuration here
225
226  target 'myapp' do
227  end
228
229  target 'myapp-dev' do
230  end
231end
232```
233
234Open project in Xcode, click on the project name in the navigation panel, right click on the existing target, and click "Duplicate":
235
236<ImageSpotlight
237  alt="Duplicate Xcode target"
238  src="/static/images/eas-build/variants/1-ios-duplicate-target.png"
239  style={{ maxWidth: 720 }}
240/>
241
242Rename the target to something more meaningful, e.g. `myapp copy` -> `myapp-dev`.
243
244Configure a scheme for the new target:
245
246- Go to `Product` -> `Scheme` -> `Manage schemes`.
247- Find scheme `myapp copy` on the list.
248- Change scheme name `myapp copy` -> `myapp-dev`.
249- By default, the new scheme should be marked as shared, but Xcode does not create `.xcscheme` files. To fix that, uncheck the "Shared" checkbox and check it again, after that new `.xcscheme` file should show up in the **ios/myapp.xcodeproj/xcshareddata/xcschemes** directory.
250
251<ImageSpotlight
252  alt="Xcode scheme list"
253  src="/static/images/eas-build/variants/2-scheme-list.png"
254  style={{ maxWidth: 720 }}
255/>
256
257By default, the newly created target has separate **Info.plist** file (in our case it's **ios/myapp copy-Info.plist**). To simplify your project we recommend using the same file for all targets:
258
259- Delete **./ios/myapp copy-Info.plist**.
260- Click on the new target.
261- Go to `Build Settings` tab.
262- Find `Packaging` section.
263- Change **Info.plist** value - **myapp copy-Info.plist** -> **myapp/Info.plist**.
264- Change `Product Bundle Identifier`.
265
266<ImageSpotlight
267  alt="Xcode build settings"
268  src="/static/images/eas-build/variants/3-target-build-settings.png"
269  style={{ maxWidth: 720 }}
270/>
271
272To change the display name:
273
274- Open **Info.plist** and add key `Bundle display name` with value `$(DISPLAY_NAME)`.
275- Open `Build Settings` for both targets and find `User-Defined` section.
276- Add key `DISPLAY_NAME` with the name you want to use for that target.
277
278To change the app icon:
279
280- Create a new image set (you can create it from the existing image set for the current icon, it's usually named `AppIcon`)
281- Open `Build Settings` for the target that you want to change icon.
282- Find `Asset Catalog Compiler - Options` section.
283- Change `Primary App Icon Set Name` to the name of the new image set.
284