82

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)

Screenshot added

Jayprakash Dubey
  • 35,723
  • 18
  • 170
  • 177
Stig Omdal
  • 821
  • 1
  • 6
  • 5
  • Which frameworks do use? Which iOS is running on your device? – return true Sep 29 '14 at 16:54
  • @return true - iOS 8 I have the following frameworks in my game: UIKit, AdSupport, CoreGraphics, AudioToolbox, AVFoundation, CoreTelephony, MessageUI, SystemConfiguration, Accelerate, Foundation, SpriteKit. Wrote down all of them :D – Stig Omdal Sep 29 '14 at 17:12
  • possible duplicate of [dyld: Library not loaded: @rpath/libswift\_stdlib\_core.dylib](http://stackoverflow.com/questions/24002836/dyld-library-not-loaded-rpath-libswift-stdlib-core-dylib) – Sruit A.Suk Jun 20 '15 at 20:27
  • I had this problem after moving to a new mac. [The cause was a missing apple WWDR intermediate certificate.](http://stackoverflow.com/a/14495100/860488) – Morten Holmgaard Oct 14 '15 at 09:57
  • in a real device i tested whole ways and did not get answer, but finally I removed cocoaPod from my project and again reinstall it, the problem solved and my app run in device!! this is the remove cocoaPod answer : stackoverflow.com/a/34765245/2201814 – MHSaffari Feb 12 '18 at 06:58
  • Possible duplicate of [dyld: Library not loaded: @rpath/libswiftCore.dylib](https://stackoverflow.com/questions/26024100/dyld-library-not-loaded-rpath-libswiftcore-dylib) – Cameron Lowell Palmer Mar 10 '18 at 08:44
  • Check out this https://stackoverflow.com/a/52129141/2020034. It works – Vinayak Parmar Sep 01 '18 at 14:40
  • This answer solved it for me: https://stackoverflow.com/a/52129141/1386213 – user1386213 May 09 '19 at 18:03
  • none of the above solution worked for me,i solved the problem with this solution: https://stackoverflow.com/a/58796525/401403 – Arash Nov 12 '19 at 07:50
  • Noting but this [thread](https://stackoverflow.com/questions/71943856/error-library-not-loaded-rpath-libswiftcore-dylib-in-flutter-for-ios) worked for me. – Vic85 Aug 18 '23 at 08:01

30 Answers30

90

Try adding the following line to Runpath Search Paths of your target.

@executable_path/Frameworks

your_target -> Build Settings -> Linking -> Runpath Search Paths

Amr Hossam
  • 2,313
  • 1
  • 22
  • 23
  • 55
    in my **Runpath Search Paths** i already having this by default – S P Balu Kommuri Feb 20 '15 at 04:57
  • 3
    solved! thanks! I would suggest to clean the project too: `shift + cmd + k` – ric Aug 02 '16 at 16:36
  • In my case, this error was happening after I merged in another branch where I had created a Today Extension (Widget). After a merge conflict, the runpath for my merged widget-target had been corrupted somehow, and did not contain the proper runpath. When jumping back to the widget pre-merge i noticed it had these two runpaths: `@executable_path/Frameworks` `@executable_path/../../Frameworks` (in addition to the `$(CONFIGURATION_BUILD_DIR)`) – Sti Dec 21 '16 at 12:03
  • In my case, I created two targets, and I added a Swift 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. After adding this two settings, the second target started to work properly. – Diego Carrera Mar 12 '19 at 09:18
51

I had this same issue. I ended up adding the framework in the following locations:

  1. General > Embedded Binaries
  2. General > Linked Frameworks and Libraries
  3. Build Phases > Link Binaries with Libraries

The embedded binaries seemed to be the key for me.

pkamb
  • 33,281
  • 23
  • 160
  • 191
zoruc
  • 819
  • 7
  • 13
  • 3
    Embedded Binaries! That seemed to be the key missing from many other answers seen here for me – bitwit Oct 21 '15 at 00:10
  • This issue occurred while referring my "SharedCode.framework" . Adding .framework in application Target>General>"Embedded Binaries" solved the issue. – Alphonse R. Dsouza Mar 04 '16 at 12:08
29

For me helps adding @executable_path/Frameworks to the project Runpath Search Paths, not target. enter image description here your_project -> Build Settings -> Linking -> Runpath Search Paths

Vitalii Gozhenko
  • 9,220
  • 2
  • 48
  • 66
15

None of the other solutions helped me, but everything was fixed by deleting Xcode's Derived Data directory.

Carl Veazey
  • 18,392
  • 8
  • 66
  • 81
ex3ndr
  • 183
  • 2
  • 7
  • Yes, this worked for me. I was previosuly only deleting the derived data for the specific project, but needed to delete Xcode's derived data folder. Thank you. – vikzilla Dec 30 '15 at 22:31
  • 6
    Where is the **Derived Data**? – JW.ZG Oct 03 '16 at 15:05
  • 2
    DerivedData directory can be found at Xcode -> Preferences -> Locations then click the arrow to take you to the directory – Caroline Sep 12 '17 at 00:47
13

Oh yes. I've faced with that problem spending hours on solution. You may try to set "Always Embed Swift Standard Libraries" to "Yes" under your Build Settings > Build Options

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

(don't forget to shift+cmd+K your project after)

user2077469
  • 1,079
  • 1
  • 9
  • 13
11

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.

Justin Domnitz
  • 3,217
  • 27
  • 34
11

In the Framework Target (not the app target), go to Build Settings > Build Options > Always Embed Standard Swift Libraries to YES.

This solved the issue for me!

zekel
  • 9,227
  • 10
  • 65
  • 96
Islam Magdy
  • 111
  • 1
  • 2
9

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

Santa Claus
  • 984
  • 1
  • 12
  • 26
  • This fixed it for me. Couldn't even run a vanilla command-line app without the dlyd error. – RobertJoseph Apr 07 '19 at 13:25
  • This was also the fix for me. I encountered this error on a brand-new Swift project (hello world) with OS version 10.14.3. Upgraded to 10.14.4 and it worked. – Ross Tajvar Apr 11 '19 at 04:11
8

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 :

  1. Drag and drop your swift framework in your project and move in default Framework folder of your project.
  2. Then add them as Embedded binaries as shown in screenshot.
  3. Change your framework status from Required to Optional as shown in screenshot. (Build Phases > Link Binary with Library)

enter image description here

  1. Set Always Embed Swift Standard Libraries to Yes in your build settings.

  2. Set Subpath and select destination as Framework for your added framework in Build Phases> Embed frameworks as shown in screenshot. enter image description here

Hope it will help someone.

Aashish1aug
  • 795
  • 1
  • 8
  • 22
  • If we make framework as Optional then the framework classes which we access in code are nil. Do you have any solution for this? – Vijay Sep 24 '18 at 12:39
  • Could you please tell, how did you get this AirWatch SDK? I've have troubles with it. here is my question: https://stackoverflow.com/questions/53023149/how-can-i-download-airwatch-ios-sdk – Alex Oct 29 '18 at 08:52
  • Thanks!, this is the only solution that worked for me! +1 – batman Dec 13 '18 at 04:04
  • @akdsouza Good to hear :) – Aashish1aug Dec 13 '18 at 07:03
5

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"

Saikiran Komirishetty
  • 6,525
  • 1
  • 29
  • 36
5

I fixed by deleting all from Xcode Derived Data directory:

~/Library/Developer/Xcode/DerivedData

Good luck all!

pkamb
  • 33,281
  • 23
  • 160
  • 191
Mihail Salari
  • 1,471
  • 16
  • 17
4

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.

Paul Popiel
  • 930
  • 11
  • 21
  • I tried every possible scenario discussed everywhere, but nothing seems to work, i am positive that the framework i am using is built on different Swift version, but i am not sure if it is the problem. I'll try re building the framework for newer version of Swift and will share the status here. – Faran Rasheed Oct 04 '17 at 04:53
  • I think it was the case for me - was using Xcode 9.2 with framework using Swift 4.1 which needs Xcode 9.3. – Fenix Voltres Sep 11 '18 at 10:03
3

I had the same error message, that is how I solved it :

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 : - Go to developer.apple.com / certificates --> Revoke certificates OR go in Xcode > preferences > accounts > View details > select Sigining identities > clic setting whell > revoke - Got to developper.apple.com and follow instructions to generate new certificates - In Xcode in my project : go to Code Signing Identity and sign both Debug lines with the generated certificate - Both release lines are set to "iOS Developer" - Then project > clean - Build and run on device

Etienne
  • 46
  • 1
3

@Saikiran's answered worked.

My certificates were generated before iOS 8 was released. I revoked all my certificates and regenerated all provisioning profiles and it solved my problems immediately.

I don't have enough reputation to vote up @Saikiran's answer, but that definitely helped solving the problem.

BumMo Koo
  • 1,119
  • 1
  • 8
  • 11
2

For me has worked set the option

ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES

to YES in Project -> Build Settings -> Build Options

(Namirial framework through Cocoapods)

Daniele Ceglia
  • 849
  • 8
  • 12
2

None of the above solutions worked for me. 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

Vinayak Parmar
  • 608
  • 10
  • 18
1

I had the same error message, this is how I solved it : This is happening because i changed bundle identifier, so i just put old bundle id and it started to work again

MJ_iOSDev
  • 145
  • 10
Bhadresh Sonani
  • 90
  • 1
  • 11
1

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.

jkestner
  • 19
  • 4
1

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.

Community
  • 1
  • 1
Dan Lee
  • 101
  • 1
  • 5
1

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 wasn't able to add a comment and wanted to provide more clarity.

Randoramma
  • 123
  • 9
1

For me Cleaning the project solve the issue!

Navid
  • 901
  • 9
  • 20
1

I got such issue, too All other ways could not help me, so 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! I think it is the last way for it, maybe could help you

1

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.

Diego Carrera
  • 2,245
  • 1
  • 13
  • 16
1

Try cleaning the build folder, I was having the same problem and I solved it this way: Product -> Clean Build Folder

FarouK
  • 740
  • 6
  • 17
0

For Me restart simulator solved this problem.

Karen Hovhannisyan
  • 1,140
  • 2
  • 21
  • 31
0

I tried a bunch of the cases above and it didn't seem to solve my issue. I use git and cocoapods for a project, and the error went away as soon as I made a new commit.

Oliver S
  • 993
  • 1
  • 9
  • 11
0

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

0

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.

Xavier
  • 8,828
  • 13
  • 64
  • 98
0

In my case Mac M1, xcode 14.3.1: I added /usr/lib/swift to Runpath Search Paths then it worked:

Tao Nhu
  • 1,980
  • 1
  • 15
  • 6
0

After I've tried many ways, I found another way that solves my problem. 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, then problem is resolved.

Mesird
  • 31
  • 5