iOS app crashes at launch on Testflight for iOS 14 and below but not iOS 15+
Basically, there is a reference to the new swift concurrency likely in a third party library of your application in use.
See these threads for details: https://forums.swift.org/t/app-distributed-via-testflight-crashes-on-launch/53936/6 and on apple forums https://developer.apple.com/forums/thread/696197
3 official work arounds:
- use Xcode 13.1 with bitcode disabled for archives (not good because then app store can't recompile on the server to support new toolchains etc)
- use Xcode 13.2 RC as normal (however, will then fail for iOS 12 devices with chkstk_darwin symbol issue) (UPDATE: Xcode 13.2.1 still has a crashing issue for iOS 12, so still wouldn't recommend the updated Xcode fix. EDIT: it looks like Xcode 13.3 BETA has additionally fixed the iOS 12 crash according to release notes. I have not confirmed yet personally.)
- add libswift_Concurrency.tbd in the "Link Binary with Libraries" build phase (and make it optional). (seems to be the most ideal solution)
The resulting crash would look something like this: Exception Type: EXC_CRASH (SIGABRT) Exception Codes: 0x0000000000000000, 0x0000000000000000 Exception Note: EXC_CORPSE_NOTIFY Termination Description: DYLD, dyld: Using shared cache: A194BE38-C853-3272-8F62-1028DD9E9B9B | dependent dylib '@rpath/libswift_Concurrency.dylib' not found for '/private/var/containers/Bundle/Application/869587C8-912F-4A90-93DC-F5C6B531AC13/Her.app/Her', tried but didn't find: '/usr/lib/swift/libswift_Concurrency.dylib' '/private/var/containers/Bundle/Application/869587C8-912F-4A90-93DC-F5C6B531AC13/Her.app/Frameworks/libswift_Concurrency.dylib' '@rpath/libswift_Concurrency.dylib' '/usr/local/lib/libswift_Concurrency.dylib' '/usr/lib/libswift_Concurrency.dylib' Highlighted by Thread: 0
You can find the crash log via Settings -> Privacy -> Analytics & Improvements -> Analytics Data since you won't be able to get it anywhere else or get the device logs when connected to xcode with physical device and it goes through the crash.
We've ended up finding a solution for our issue:
- we're using the new Xcode 13.2RC (not ideal since it's not a final release yet, but no luck without it) - you'll need the latest MacOS to run it
- we've removed support for iOS 12 from our build (which thankfully we could afford to do since only a tiny fraction of our users were still using that version) These 2 things are both required on our end, trying to do one without the other would still show us the crashes.
I don't know if this is going to be the solution for everybody, so here are a couple of links we've used to get some ideas:
- https://developer.apple.com/forums/thread/696197
- https://developer.apple.com/forums/thread/696463 (that's our own Apple forum thread, but it has other ideas)
Also wanted to add to the things we've tested while debugging:
- From Xcode Organizer, distributing as Dev or Ad Hoc an archive that presents the issue on Testflight does NOT present the issue when installing directly to device, which reinforces the idea this is not a code/archive issue
- We've switched automated app signing to manual using all sorts of provisioning profiles (ad hoc, dev & distribution, using either iOS-only or Apple certificates), and the issue only presents itself when distributing to Testflight/Store using the distribution profiles
At the end of the day, it does look like an Apple issue and we would expect to see a fix soon - especially since more and more people have been faced with a similar problem.