iakta/flutter_flavors

How to use?

Opened this issue · 5 comments

Hi there, just found your excellent blog post on flutter flavors. Its something I've been seriously struggling with the past couple of weeks - just how do we use flutter to get production archives that have different bundle id's. Everything I've tried seems to break the flutter build tools.

btw. I could not work out how to post comments on your website - hence this is an issue - feel free to delete if theres a better way to communicate.

I'm just wondering - after setting up the config and schemes in Xcode as per your post - what is now the typical developer workflow?

i.e. I still use IntelliJ or VSCode to develop and run on my own phone and sims.
But when I want to build the app and send it to QA testers for example - what would you do? Run flutter build ios --flavor qa. Do I then distribute the binary that is created or do I still need to go into Xcode and switch to the qa scheme and then run Product->Archive to get the app to send to testers?

I'm new to iOS as you can probably tell. ;-)

Hi,

TLDR: we use XCode to distribute and do real tests on iOS devices (looking at logs, breakpoints in native plugins etc..).

Longish story is:
usually our pipeline is like this

  • develop eveything on AndroidStudio + FlutterPlugin, then test on Android devices
  • test sometimes on iOS devices running from AndroidStudio,
  • for native Swift/ObjC code plugins, write and run from XCode

When ready for production or staging (i.e. releasing via TEstFlight to developers) we do

  • build a test (for us the flavor is staging) release on AndroidStudio and test on Android
  • run this command
    flutter build ios --release --flavor staging -t lib/main-staging.dart
  • switch to XCode, select appropriate target/schema and an iOS device and
  • do a Run/Archive
  • then upload to iTunesConnect

Hope it helps..

Appreciate your help. ;-)
When I run the flutter build ios —release —flavor staging I get the build errors mentioned above so can’t get past that step. There must be other config required somewhere....

Just realised I didn’t specify the errors. Away from my computer now but the first was that Xcode could not find the generated xcconfig files that we reference in the new config files. The others were a bunch of crazy cocoa pods errors. I’ll come
Back to this tomorrow. ;-)

The iOS part does not work.
In the IDE I created the two flavor configurations, then run development on the ios simulator: Output:

Launching lib/main-dev.dart on iPhone Xʀ in debug mode...
Removing obsolete reference to flutter_assets from Runner.app
Running Xcode build...
Xcode build done.                                           17.8s
ProcessException: Process "/usr/bin/xcrun" exited abnormally:
it.iakta.flutterFlavors$(bundle_suffix): -1

An error was encountered processing the command (domain=FBSOpenApplicationServiceErrorDomain, code=1):
The request to open "it.iakta.flutterFlavors$(bundle_suffix)" failed.
The request was denied by service delegate (SBMainWorkspace) for reason: NotFound ("Application "it.iakta.flutterFlavors$(bundle_suffix)" is unknown to FrontBoard").
Underlying error (domain=FBSOpenApplicationErrorDomain, code=4):
	The operation couldn’t be completed. Application "it.iakta.flutterFlavors$(bundle_suffix)" is unknown to FrontBoard.
	Application "it.iakta.flutterFlavors$(bundle_suffix)" is unknown to FrontBoard.
  Command: /usr/bin/xcrun simctl launch 6A5CD5B3-0A2F-42CF-B593-10E63D82575E it.iakta.flutterFlavors$(bundle_suffix) --enable-dart-profiling --enable-checked-mode --verify-entry-points --observatory-port=0
Error launching application on iPhone Xʀ.

Then run production:

Launching lib/main.dart on iPhone Xʀ in debug mode...
Running Xcode build...
Xcode build done.                                            9.3s
ProcessException: Process "/usr/bin/xcrun" exited abnormally:
it.iakta.flutterFlavors$(bundle_suffix): -1

An error was encountered processing the command (domain=FBSOpenApplicationServiceErrorDomain, code=1):
The request to open "it.iakta.flutterFlavors$(bundle_suffix)" failed.
The request was denied by service delegate (SBMainWorkspace) for reason: NotFound ("Application "it.iakta.flutterFlavors$(bundle_suffix)" is unknown to FrontBoard").
Underlying error (domain=FBSOpenApplicationErrorDomain, code=4):
	The operation couldn’t be completed. Application "it.iakta.flutterFlavors$(bundle_suffix)" is unknown to FrontBoard.
	Application "it.iakta.flutterFlavors$(bundle_suffix)" is unknown to FrontBoard.
  Command: /usr/bin/xcrun simctl launch 6A5CD5B3-0A2F-42CF-B593-10E63D82575E it.iakta.flutterFlavors$(bundle_suffix) --enable-dart-profiling --enable-checked-mode --verify-entry-points --observatory-port=0
Error launching application on iPhone Xʀ.

Note on the simulator I have now 2 icons for each build flavor and they work when starting it manually, but integrated this does not work - prop due to flutter issues not "finding" the correct app to open.

I create an issue flutter/flutter#31891 and there might me already a PR flutter/flutter#31039 for it...