Flutter Flavoring — Existing iOS project
Hello Everyone !! we flavored our android app and now turn to the iOS app, I found it a bit tricky to add a new flavor to an existing project so just thought to share my work.
Step 1. Open the ios folder from the flutter project in XCode. Adding files using XCode is necessary for iOS configuration in the flutter project, if we simply drag and drop files under the ios folder in the flutter project without XCode, we didn’t get all configuration.
Step 2. Click on Runner(project), create a new scheme say as dev
Step 3. Now we have to create a build configuration for dev, select Project Runner, info->configurations
By clicking on + sign we can duplicate the configuration and rename it like Debug-dev, Release-dev and Profile-dev
Step 4: Let's rename the original configuration as a prod
Step 5: As we created dev from existing build configuration, now we can rename existing configuration as prod :
Step 6: Now we have two different schemes dev and prod with their own build configuration settings, we can customize it further.
First set bundle identifier for these flavors.
Here our bundle identifier is com.yogita.addFlutterAppToFirebase, so I just add .dev at the end so that we can differentiate envoirnments com.yogita.addFlutterAppToFirebase.dev
Step 7: Add GoogleService-Info.plist file in our project, download these files from firebase. And explicitly add to our project.
For more information please refer integration of iOS app to firebase
Step 8: Next we have to add a step in the build process so that the correct GoogleService-Info.plist file gets picked.
For that add Copy GoogleService-Info.plist file to the corresponding location by clicking on + button at the top and rename it.
I have added below in the script:
Now we can run the project with the following command
flutter run --flavor dev
Note: Follow the same steps to create a staging environment.
And we are done!