When I upgrade my Xcode to 14, my app crashed and Get an error message: dyld: Library not loaded: /usr/lib/swift/libswiftCoreGraphics.dylib
It's only happen on devices with iOS version below 13,like iOS 12/11,
When I upgrade my Xcode to 14, my app crashed and Get an error message: dyld: Library not loaded: /usr/lib/swift/libswiftCoreGraphics.dylib
It's only happen on devices with iOS version below 13,like iOS 12/11,
most likely an interoperability issue between Xcode 14 and older iOS version devices. It has been reported multiple times in GitHub issues. Check this post in Apple Developer Forum.
So for solutions: add libSwiftCoreGraphics.tbd
to your project's Frameworks,Libraries,and Embeded Contents
.
If you are using pods or SPM, also check the updates from the author. For example, SnapKit
just upadted their podfile 5 days ago
As per https://developer.apple.com/forums/thread/714795, Apple suggested adding -Wl,-weak-lswiftCoreGraphics
to the linker flags.
The problem was that without this flag your app will expect libswiftCoreGraphics.dylib
to be at /usr/lib/swift/libswiftCoreGraphics.dylib
on the phone. Because the dylib isn't there on older iOS versions, you'll get error like
EXC_CRASH (SIGABRT)
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Termination Description: DYLD, Library not loaded: /usr/lib/swift/libswiftCoreGraphics.dylib
Adding the flag tells the linker to treat this library as a weak linker flag. At the launch(or load) time, the dylib will be searched relative to the @rpath
instead of hard coded /usr/lib/swift
path.
You can learn more about rpath
and how that helps dyld
find the dylibs here
After running otool -L
on the app I see few more libraries pointing to their /usr/lib/swift
version but all of them are weak references e.g,
/usr/lib/swift/libswiftCoreMIDI.dylib (compatibility version 1.0.0, current version 6.0.0, weak)
/usr/lib/swift/libswiftCoreML.dylib (compatibility version 1.0.0, current version 1436.0.14, weak)
/usr/lib/swift/libswiftDataDetection.dylib (compatibility version 1.0.0, current version 723.0.0, weak)
/usr/lib/swift/libswiftFileProvider.dylib (compatibility version 1.0.0, current version 730.0.125, weak)
/usr/lib/swift/libswiftOSLog.dylib (compatibility version 1.0.0, current version 4.0.0, weak)
...
The only library with non-weak reference was libswiftCoreGraphics
before adding the linker flag.
/usr/lib/swift/libswiftCoreGraphics.dylib (compatibility version 1.0.0, current version 120.100.0)
After adding the linker flag it appears as:
@rpath/libswiftCoreGraphics.dylib (compatibility version 1.0.0, current version 15.0.0, weak)
/usr/lib/swift/
with @executable_path to the LD_RUNPATH_SEARCH_PATH to make it search in all possible places? instead of weak linking. What will happen if he try to embed and SDK that depend on this libs the weak link wont help here, no? –
Farnese /usr/lib/swift/
is already added and that is why the setup was working for iOS>12. But on iOS-12.1 the library isn't there. Making libswiftCoreGraphics
relative to @rpath the loader is searching for all places as you mentioned. –
Hollywood most likely an interoperability issue between Xcode 14 and older iOS version devices. It has been reported multiple times in GitHub issues. Check this post in Apple Developer Forum.
So for solutions: add libSwiftCoreGraphics.tbd
to your project's Frameworks,Libraries,and Embeded Contents
.
If you are using pods or SPM, also check the updates from the author. For example, SnapKit
just upadted their podfile 5 days ago
I got it after updating some pod to Dynamic lyb. Just clean Derived Data, Clean project and run again
Here are some steps to Solve the issue. Based on error below methods may helps you to solve the issue. Xcode Version 15.4 (15F31d)
First Update All POD to Latest
By deleting Xcode's Derived Data directory.
OR
In the Framework Target (not the app target), go to Build Settings > Build Options > Always Embed Standard Swift Libraries to YES.
OR
Min Deployment to 13.0
AND
Clean the build folder: Product -> Clean Build Folder
© 2022 - 2025 — McMap. All rights reserved.