dyld iOS 13 crash on launch

We have an app that has a deployment target of iOS 13.0 and was built using Xcode 13.2.1.

An embedded custom framework implements an iOS 14 widget, has a deployment target of iOS 14, and weak links against WidgetKit and SwiftUI.

When running on iOS 13.0-13.3.x we are getting a crash on launch:

Symbol not found: _swift_getTypeByMangledNameInContextInMetadataState\n  Referenced from: /private/var/containers/Bundle/Application/AA26538A-91B0-4B27-BA5D-0C0CEA30CEED/X.app/Frameworks/WidgetUI.framework/WidgetUI (which was built for iOS 14.0)\n  Expected in: /usr/lib/swift/libswiftCore.dylib\n

(BTW it took some work to get this message. dyld's ImageLoaderMachO::throwSymbolNotFound results in a failed_throw which terminates the app without any messages. So I had to create a symbolic breakpoint for ImageLoaderMachO::throwSymbolNotFound and step thru the assembly in lldb as the exception string was getting built)

On iOS 13.4.x-13.7, we don't see a crash which appears to be because swift_getTypeByMangledNameInContextInMetadataState got introduced in iOS 13.4.

Looking at nm -a on the iOS 14.0 framework it appears that linking against SwiftUI is what's causing the framework to reference _swift_getTypeByMangledNameInContextInMetadataState

The custom framework is not marked as optional in our production code, but changing it to optional doesn't fix the crash.

Anything else we could try to avoid this crash?

side note: When I run otool -L on the framework all the swift libraries have a prefix of /usr/lib/swift. For example /usr/lib/swift/libswiftCore.dylib Is this correct?

The easiest fix is to raise your deployment target to 13.4. IMO that’s the right thing to do anyway. There are no devices running 13.0 that can’t update to the lastest 13.x, and users who haven’t done that are missing out on some really critical security fixes.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

dyld iOS 13 crash on launch
 
 
Q