App Crashes Only On Testflight Build

I have created an app on swift and tested it extensively using iPhone 6, iPhone 6 plus and iPhone 5 devices and all the simulators offered in Xcode. The app runs fine and does not crash when uploaded locally. (iOS 8)

I finally submitted a build for Testflight. The app consistently crashes at the same place after downloading the app through the Testflight build.

Is there a known issue where uploaded builds run differently than locally created builds? And how can I debug the issue with the Testflight build?


Solution 1:

I guess its a swift compiler issue. To verify first go to Edit Scheme then change the Build configuration to Release mode in Run tab and then install the build locally. You will get to know where exactly its crashing.

Solution 2:

I solved the issue by changing the swift compiler optimization from fastest to none. I'm not sure if this is an ideal long term solution, but the build no longer crashes.

Solution 3:

In my case this happened after starting to use Xcode 11. It was a UISearchDisplayController (deprecated since iOS 8) that seems to work on a device or simulator in debug mode, but not in the release build. Xcode 11.3 doesn't give any inline warning in the code. The crash was hard to find, because the search controller wasn't used any more, it was orphaned code.

Solution 4:

It might be the Bitcode related issue. Check if your all third-party libraries support bitcode then and then only set bitcode to YES else set to NO.

Actually Bitcode is an intermediate representation of a compiled program. Apps you upload to iTunes Connect that contain bitcode will be compiled and linked on the App Store.