Dyld: Library Not Loaded: @Rpath/Libswift_Stdlib_Core.Dylib

dyld: Library not loaded: @rpath/libswift_stdlib_core.dylib

For me none of the previous solutions worked. We discovered that there is a flag ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES (in earlier versions: "Embedded Content Contains Swift Code") in the Build Settings that needs to be set to YES. It was NO by default!

dyld: Library not loaded: @rpath/libswift_stdlib_core.dylib when running on iPhone

I'm guessing your iPhone 4S is lower than iOS 6. We also did regression tests on iPhone 4S's on iOS 6 and 7 but they were all fine. Devices on iOS 5 and 5.1 had the same error as you have though.

dyld: Library not loaded: @rpath/libswift_stdlib_core.dylib

For me none of the previous solutions worked. We discovered that there is a flag ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES (in earlier versions: "Embedded Content Contains Swift Code") in the Build Settings that needs to be set to YES. It was NO by default!

dyld: Library not loaded: @rpath/libswiftDispatch.dylib

I am using AVG Free for Mac. Yesterday it removed libswiftDispatch.dylib to quarantine because of 'MacOS:BitCoinMiner-AS'. This seems like a false positive, see:
https://discussions.agilebits.com/discussion/86860/avg-quarantined-1password-libswiftdispatch-dylib/p2
https://forum.avast.com/index.php?topic=216164.msg1449648#msg1449648 (AVG and Avast are the same company)

So for me the fix was restoring this file from quarantine.

dyld: Library not loaded: @rpath/libswiftAVFoundation.dylib Reason: image not found

When including a framework built with Swift in a non-Swift project, the Swift standard libraries need to be copied into the final output. Xcode has a checkbox for this (#4 in the original question), but apparently there's a bug where, in some cases, it doesn't actually happen.

I saw another thread somewhere that said this happens when you have a framework built with Swift, which is built for multiple architectures, such as armv7 and arm64. (See the thread here.)

In any case, the solution is to add them all manually. The files you are looking for are in /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos.

What I did was this:

Step 1. Open Terminal and type this, copying the libraries to a new folder, swiftStdLib, in your home directory.

cd /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos
mkdir ~/swiftStdLib
cp libswift*.dylib ~/swiftStdLib

Step 2. Within Xcode, go to General -> Embedded Binaries, and hit the + to add. Click Add Other, then navigate to your home folder/swiftStdLib. Select all and hit enter.

Step 3. Clean and build the project.

Hope this helps someone.

UPDATE FOR XCODE 11:

In Xcode 11.3, the Swift libraries folder has changed to include the major Swift version number. The original question was based on Xcode 9, so this probably changed earlier than Xcode 11.3, but I haven't checked.

The new folder is /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-5.0/iphoneos.

So that makes Step 1, above, this instead:

cd /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-5.0/iphoneos
mkdir ~/swiftStdLib
cp libswift*.dylib ~/swiftStdLib


Related Topics



Leave a reply



Submit