Reputation: 841
I am running my app from xcode to my iOS device and I get this and black screen on iOS device.
Console text:
dyld: Library not loaded: @rpath/libswiftCore.dylib
Referenced from: /private/var/mobile/Containers/Bundle/Application/10DB2FE8-EF09-4857-B4AC-0DB2E4419D6F/App-Name.app/App-Name
Reason: image not found
(lldb)
Upvotes: 84
Views: 71862
Reputation: 1378
Here are some steps to Solve the issue. Based on error below methods may helps you to solve the issue.(XCode Version Version 15.4 (15F31d))
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
Upvotes: 0
Reputation: 9354
Add @executable_path/Frameworks
to the project Runpath Search Paths, not target.
your_project -> Build Settings -> Linking -> Runpath Search Paths
Upvotes: 29
Reputation: 1179
Set "Always Embed Swift Standard Libraries" to "Yes" under your Build Settings > Build Options
(Don't forget to Shift+Cmd+K your project after)
Upvotes: 13
Reputation: 819
Add the framework in the following locations:
General > Embedded Binaries
General > Linked Frameworks and Libraries
Build Phases > Link Binaries with Libraries
The embedded binaries seemed to be the key for me.
Upvotes: 51
Reputation: 2323
Add the following line to Runpath Search Paths of your target.
@executable_path/Frameworks
your_target -> Build Settings -> Linking -> Runpath Search Paths
Upvotes: 90
Reputation: 845
Set the option
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES
to YES in Project -> Build Settings -> Build Options
(Namirial framework through Cocoapods)
Upvotes: 2
Reputation: 133
Seems this issue was caused by the inclusion of Swift file into objective-c custom framework. Also unsure if related but my app target was built in objective-c as well. Also building to simulator in debug. Haven't verified for release or archive build yet.
Additionally Runpath Search Settings for the project target were set to "@executable_path/Frameworks", within the target settings for the framework they were set to: "@executable_path/Frameworks" and "@loader_path/Frameworks".
After having tried rebuilding custom framework and reattaching to app target, clearing derived data folder and a couple other suggestions, what ultimately worked for me was changing the build setting within Project target for the custom framework project (not app target): "Always Embed Swift Standard Libraries" to "YES". It appeared not to matter what the setting for the app target was set to. I verified this by resetting the simulator and rebuilding. This is similar to Daniele Ceglia's answer but I wanted to provide more clarity.
Upvotes: 1
Reputation: 46
The issue came from the certificates generated automatically by Xcode. I had to revoke these certificates dans generate them back from developer.apple.com
The solution is then:
Upvotes: 3
Reputation: 61
Just create a dummy.swift in your project, and Xcode would pop a window remind you whether need to create a bridge header, choose yes.
Upvotes: 0
Reputation: 90
This is happening because I changed bundle identifier, so I just put old bundle id and it started to work again.
Upvotes: 1
Reputation: 1581
I fixed by deleting all from Xcode Derived Data directory:
~/Library/Developer/Xcode/DerivedData
Upvotes: 5
Reputation: 618
I changed the iPhone Developer Certificate trust settings in Keychain. It should be Always Trust. Change it to Use System Defaults. Double click the certificate in Keychain to open the option screen Discovered that from this blog
Upvotes: 2
Reputation: 1423
I have done it on stupid way created new project and pod install from scratch and after confirmed it is working correctly, I copied all class files and storyboard files, at last done!
Upvotes: 1
Reputation: 111
In the Framework Target (not the app target), go to Build Settings > Build Options > Always Embed Standard Swift Libraries to YES.
Upvotes: 11
Reputation: 805
In my case, This issue is coming in Objective-c project in which I am using a Swift framework (AirWatch SDK).
Solutions: I have resolved this issue with Xcode 9.3 and 11.0.1 iOS as mentioned bellow steps :
Set Always Embed Swift Standard Libraries to Yes in your build settings.
Set Subpath and select destination as Framework for your added framework in Build Phases> Embed frameworks
as shown in screenshot.
Upvotes: 8
Reputation: 2050
In my case Mac M1, xcode 14.3.1: I added /usr/lib/swift to Runpath Search Paths then it worked:
Upvotes: 0
Reputation: 9079
I have an objective-c project, and this problem showed up after updating the Firebase version in Cocoapods. I added a new swift file (File->New->File) and was asked if I wanted to add a bridging header. I selected Yes, which fixed the problem.
Upvotes: 0
Reputation: 1
Please check the *.framework If there is a _CodeSignature signature framework directory. If there is no _CodeSignature folder, Navigate to the Build Phases ,click + to add New Copy File Phase to create Copy Files. after that, reference *.framework and choose Code Sign On Copy
Upvotes: 0
Reputation: 1002
I had this error in a command line project (Xcode 10.2 and macOS 10.14.3)
The solution was to update to macOS 10.14.4
Swift command line projects won’t run on macOS 10.14.3 and earlier unless you install the Swift 5 Runtime Support for Command Line Tools package. Without that package, Swift command line projects crash on launch with “dyld: Library not loaded” errors. (46824656)
From Swift 5 Release Notes for Xcode 10.2
Upvotes: 9
Reputation: 2355
I had a similar problem in an Objective-C project where I started to include Swift files.
In my case, I created two targets in the main project, and I added a Swift empty file, that creates a bridging header file and some configurations, but I only marked it as a member of one target. The first target works properly, but the second not, and I noticed that the differences in build settings were this setting:
Runpath Search Paths ->
$(inherited)
and@executable_path/Frameworks
And I also needed to reference Objective-C Bridging Header to the file that was created before:
Objective-C Bridging Header ->
pathTo/Target-Bridging-Header.h
After adding this two settings, the second target started to work properly.
Upvotes: 1
Reputation: 1010
This error message can also occur when using a framework build in a different Swift version then the one currently being used, e.g. if you upgrade Xcode.
Upvotes: 4
Reputation: 111
I had this problem before in iPod touch iOS 9.3. And I used all the methods mentioned in this post, but none of them worked.
I checked my project setting. And in the other link flag, I found I added -Wl,-sectcreate,__RESTRICT,__restrict,/dev/null
.
This flag prevents dyld insert in the jailbroken phone. When I delete this flag, the app can be launched again. I am not sure why it worked. Because in iPhone se iOS 10 I don't have to delete this line. But it did work in iPod touch iOS 9.3. So check it if you have the same situation like me.
Upvotes: 1
Reputation: 19
I already had the Runpath Search Paths set correctly, but it still didn't work. @Justin Domnitz's answer put me on the right track: Setting "Always Embed Swift Standard Libraries" to Yes in my target's build settings did the trick for me.
Upvotes: 1
Reputation: 3307
I had to switch 'Embedded Content Contains Swift Code' to 'Yes' to get my Obj-C app to work after updating the Obj-C embedded framework with a Swift object.
Upvotes: 11
Reputation: 6565
I have faced the same issue, setting the right code sign identity solved the problem(Build settings->Code Signing Identity).
As per Apple technical questions "All Enterprise and standard iOS developer certificates that are created after iOS 8 was released have the new Team ID field in the proper place to allow Swift language apps to run"
Upvotes: 5