How to make multiple iOS Targets in Flutter?

前端 未结 1 898
忘了有多久
忘了有多久 2021-02-14 13:56

How can I make Flutter run a different Target for iOS that is not the default \"Runner\"?

1条回答
  •  广开言路
    2021-02-14 14:56

    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:

    1. Open your workspace in Xcode - run open ios/Runner.xcworkspace in the terminal, from your app's root.

    2. 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).

    1. 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).

    2. 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.

    1. Run your custom scheme from the command line. For example: flutter run --flavor Staging.

    2. 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

    0 讨论(0)
提交回复
热议问题