Flutter app can debug on an iOS device/simulator but crashes immediately when installed via TestFlight

Viewed 3946

Been working on an app. Everything is fine and we can debug on simulators and devices, both iOS and Android. Our Android app builds fine and the APK is up in the Play Store. The iOS app on the other hand doesn't like to be deployed via TestFlight. Building an archive, uploading to iTunesConnect and distributing the app through TestFlight we see the app crash immediately on startup.

Ensured that Bitcode is set to NO for both debug and release. Set the Optimization Level on the release target to None. That had no impact. I've verified we're signing with the right provisioning profile and signing certificate too. At first I went with the Automatic handling of that.

Any ideas or areas I should be looking to resolve the immediate crashing? Would like to submit some sort of device log but there isn't any. Odd thing is that double tapping the iOS device home button shows a white card in the stack with our app logo. So it looks like it's there... very confused.

enter image description here

2 Answers

I had this issue also. The problem for me was that after I did a release build, I made a change to something before creating the archive to push to iTunes. When you create the archive from Xcode, it defaults back to debug mode, not release mode, so the app runs on local ios devices and simulators but crashes when deployed via TestFlight.

The fix is to precisely follow the instructions to Create A Build Archive each time, and if you make any change to the project not specified in those instructions, start over by creating a new release build.

The developer UX around this is a known issue being tracked here: https://github.com/flutter/flutter/issues/12086

Extending on what @FrederickCook answered...

  1. Go to you ios/Podfile and look for:
ENV['FLUTTER_FRAMEWORK_DIR'] = '/Users/Alex/flutter/bin/cache/artifacts/engine/ios/'

It should be in line 5.

  1. Modify it to:
ENV['FLUTTER_FRAMEWORK_DIR'] = '/Users/Alex/flutter/bin/cache/artifacts/engine/ios-release/'
  1. Run pod install inside the ios/ folder
  2. Go back to your app's root directory and run flutter build ios
  3. Open up Xcode and create your archive to download to iTunes.
Related