How can I make Flutter run a different Target for iOS that is not the default \"Runner\"?
That's going to be tricky. If you look at the output of flutter run --help
command, you will see that it supports a custom --flavor
option that allows you to specify a custom scheme.
However, several things need to be done in order to make it work:
Open your workspace in Xcode - run open ios/Runner.xcworkspace
in the terminal, from your app's root.
Clone the Runner target by expanding the project and target list, clicking on the Runner project and selecting Duplicate (more details here).
This should create a custom scheme for you as well, with its own Info.plist file. The scheme will be called Runner-copy by default, rename it to what you named your new target (e.g. Staging).
Duplicate your debug and release build configurations and name them the way Flutter expects them to be named. For example, if your new target is called "Staging", you need to create a Debug-Staging and Release-Staging build configurations (more details on doing this).
Edit the Podfile and copy the entire target 'Runner' do
section, replacing the name of the target with yours. Afterwards, run pod install
.
Now that you have two different targets, you can do things like set different bundle ids, or include different files.
Run your custom scheme from the command line. For example: flutter run --flavor Staging
.
If step #5 failed, re-run pod install
manually, open the workspace in Xcode and run from there.
Note: this is pretty fragile, use at your own risk
Note: I was not able to get this to run in release mode