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.
- I have set
Always Embed Swift Standard Libraries
to a value ofYES
in the build settings tab for both my Swift framework and in the Swift application that uses the framework. - 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. - 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
How to Find the Address of a Stack Trace in Lldb for iOS
Pass in a Type to a Generic Swift Extension, or Ideally Infer It
Invalid Image Path - No Image Found at the Path. Cfbundleicons Xcode 5
How to Pass Information Between Storyboard Segues
Marking Some Xib/Storyboard Strings as Not Localizable
Autolayout Views Make App Crash on Popviewcontroller
Cabasicanimation Rotate Returns to Original Position
Issue with Uitableview: Action Only Works Every Second Time
Uitextfield Leftview/Rightview Padding on iOS7
How to Fade a Uivisualeffectview And/Or Uiblureffect in and Out
Setting Up Uiscrollview to Swipe Between 3 View Controllers
How to Do Indexofobject or a Proper Containsobject
Fatal Error: Nsarray Element Failed to Match the Swift Array Element Type
How to Connect Multiple Buttons in a Storyboard to a Single Action
Is There a Simple Way to Edit/Modify a Uilocalnotification
How to Read Plist Without Using Nsdictionary in Swift