App Crashes Only On Testflight Build
IosObjective CXcodeSwiftIos Problem Overview
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?
Ios Solutions
Solution 1 - Ios
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 - Ios
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 - Ios
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 - Ios
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.
Solution 5 - Ios
For all those who face this similar issue, can follow these steps
Go to Xcode->widows->organiser then select crashes tab then select your app. If you have added your apple account in Xcode->preferences-> accounts then you Xcode will download all crash reports even for the testflight build.
It will have the stack trace you don't need to symbloicate it like old times. PS:- the most common which I have seen is UISearchDisplayController issue
Solution 6 - Ios
In my case, changing Legacy Build System to New Build System (for Xcode 10) solves my issue where Testflight build behaves differently. Might be helpful to someone.
Solution 7 - Ios
For anyone still having this issue working with React Native, you can run this command to run it in release mode, the same when you archive a build. That way you can debug the issue easier:
react-native run-ios --configuration Release
Solution 8 - Ios
I got it (partially!). Actually "release" implementation of UI_USER_INTERFACE_IDIOM() in swift project crashes the app.
However, still I have no clue why our app store app (objective c language based) does NOT crash.
My only guess is that it's a glitch in UI_USER_INTERFACE_IDIOM() API implementation with some language specific coding (swift vs objective c) by Apple.
Anyways, I would replace all UI_USER_INTERFACE_IDIOM() with UIDevice(). userInterfaceIdiom. I hope this helps someone!
Solution 9 - Ios
If anyone else is having the same problem, here's what my fix was:
I finally got the problem down to a loop with a if statement, akin to this -
while(condition)
{
if (check)
{
code!
}
//There was no code here
}
Notice that there's no code at the end of the loop (where the comment is). Once I added a random bit of code (in this case, incrementing a variable for output), the problem stopped.
while(condition)
{
if (check)
{
code!
}
i += 1;
output statement
}
I think this has to be a compiler error, or else my "fix" shouldn't be a fix at all. But here it is in case it helps anyone else!
Solution 10 - Ios
Instead of i += 1;
in the empty while loops.
I did this in my empty while Loop: RunLoop.current.run(until: Date(timeIntervalSinceNow: 1))
And now the TestFlight App does not bomb!
A shorter time might also work such as: RunLoop.current.run(until: Date(timeIntervalSinceNow: 0.25))
Solution 11 - Ios
Release build actually takes a different entitlement file than debug build entitlement while debugging in local.
While uploading an archive build it will take release build settings and release entitlement file by default. Make sure you have all the release settings correctly edited in the configurations.