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

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

I eventually got this working using a mix of fixes. I'm not sure if all of them are needed, but I'm documenting what seemed to work for me here, just in case anyone else can benefit by what I've found.

  1. I have set Always Embed Swift Standard Libraries to a value of YES in the build settings tab for both my Swift framework and in the Swift application that uses the framework.
  2. I have added Foundation.framework to the Linked Frameworks and Libraries section of the general tab for both my Swift framework and in the Swift application that uses the framework.
  3. I have added Foundation.framework to the Embedded Binaries section of the general tab for the Swift application that uses the framework.

With all 3 of these settings in place, I am able to build and run my application without encountering this error.

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

Runing xctests from Xcode and xcodebuild fails if simulator used - dyld: Library not loaded: @rpath/libswiftSwiftOnoneSupport.dylib issue - print()

Because this library loading error pointed to a framework I was stucked...

I tried these:
dyld: Library not loaded: @rpath/libswiftSwiftOnoneSupport.dylib

Xcode - Bundle format unrecognized, invalid, or unsuitable

References to Removed Framework in project.pbxproj File

The Always Embed Swift Standard Libraries has set to YES in the app, but I am not sure wether it has set to YES in the given framework as well.

All in all the solution was from this question: dyld: Library not loaded: @rpath/libswiftSwiftOnoneSupport.dylib

where LuisCien suggesting to specifically use print() anywhere in the code will somehow force libswiftSwiftOnoneSupport.dylib to be loaded and the issue will go away.

Tests are now running although I am very curious why this ,,hack,, works.

Also tests are only fails when I try to run it with simulator with Xcode or with xcodebuild.

swift + firebase, ios 14 - SIGABRT dyld: Library not loaded: @rpath/FBLPromises.framework/FBLPromises

With Firebase (and other networking pods), there is an issue with app clips not supporting http sockets connections, and this is an issue the google api team is dealing with right now:

https://github.com/firebase/firebase-ios-sdk/issues/6211

For other pods that won't load, make sure you have your pods listed in the podfile for both the main app and app clip, and if it still crashes when run, it is because the last phase of the build phases does not include copying the podfiles like in the regular app...

so, go to the project settings, go to your main app, and click on "build phases", then look for "[CP] Embed Pods Frameworks"...now, click on your app clip and click the + button in the upper left corner, and choose "new run script phase" and rename is "[CP] Embed Pods Frameworks", then copy each string from the original, updating the path to the path of your app clip specifically. Once this is done, the app should run on your simulator or device.



Related Topics



Leave a reply



Submit