ios - tutorial - dyld: Library not loaded: @rpath/libswiftCore.dylib




xcode tutorial for beginners (20)

After having tried out everything, I finally found out, that the build seems not always include every detail again and again. Maybe for speeding up the process... In order to ensure WHOLE packaging before running on a device, make a Clean first: Shift-Cmd-K. Then build with: Cmd-B. After that run it on your device. Easy. Kind regards to all you nice guys in that place!

I am trying to run a Swift app on my iPhone 4s. It works fine on the simulator, and my friend can successfully run it on his iPhone 4s. I have iOS 8 and the official release of Xcode 6.

I have tried

  • Restarting Xcode, iPhone, computer
  • Cleaning & rebuilding
  • Revoking and creating new certificate/provision profile
  • Runpath Search Paths is $(inherited) @executable_path/Frameworks
  • Embedded Content Contains Swift Code is 'Yes'
  • Code Signing Identity is developer

Below is the error in entirety

dyld: Library not loaded: @rpath/libswiftCore.dylib
  Referenced from: /private/var/mobile/Containers/Bundle/Application/LONGSERIALNUMBER/AppName.app/AppName
  Reason: no suitable image found.  Did find:
    /private/var/mobile/Containers/Bundle/Application/LONGSERIALNUMBER/AppName.app/Frameworks/libswiftCore.dylib: mmap() error 1 at
address=0x008A1000, size=0x001A4000 segment=__TEXT in Segment::map() mapping
/private/var/mobile/Containers/Bundle/Application/LONGSERIALNUMBER/APPLICATION_NAME/Frameworks/libswiftCore.dylib

Change Copy Pods Resources for the target from:

"${SRCROOT}/Pods/Target Support Files/Pods-Wishlist/Pods-Wishlist-resources.sh"

to:

"${SRCROOT}/Pods/Target Support Files/Pods-Wishlist/Pods-Wishlist-frameworks.sh"

For me, having tried everything with no success, what worked was to remove @executable_path/Frameworks from the Packaging section (don't know how it came to be in there in the first place)


For the device, you also need to add the dynamic framework to the Embedded binaries section in the General tab of the project.


I solved by deleting the derived data and this time it worked correctly. Tried with Xcode 7.3.1GM


I started getting this error when I removed:

@executable_path/Frameworks

from Runpath Search Paths in my build settings. Replacing it fixed everything up again (thank goodness for source control!)

I don't know how it got there, but it appears to be needed for a binary to find its embedded Swift runtime.


I think it's a bug when certificates are generated directly from Xcode. To resolve (at least in Xcode 6.1 / 6A1052d):

  1. go to the Apple Developer website where certificates are managed: https://developer.apple.com/account/ios/certificate/certificateList.action
  2. select your certificate(s) (which should show "Managed by Xcode" under "Status") and "Revoke" it
  3. follow instructions here to manually generate a new certificate: https://developer.apple.com/library/ios/documentation/IDEs/Conceptual/AppDistributionGuide/MaintainingCertificates/MaintainingCertificates.html#//apple_ref/doc/uid/TP40012582-CH31-SW32
  4. go to Xcode > Preferences > Accounts > [your Apple ID] > double-click your team name > hit refresh button to update certificates and provisioning profiles

I was having the same problem after moving to a new mac, and after hours, trying all the suggested answers in the questions, none of this worked for me.

The solution for me was installing this missing certificate. http://developer.apple.com/certificationauthority/AppleWWDRCA.cer

Found the answer here. https://.com/a/14495100/976628


I'm using Xcode 7.2. If you tried all of above and the error still occurs, try deleting the old certificate from Keychain Access! It's such a pain to finally fix this.


I'm using Xcode 8.3.3 and Xcode 9.2. The solution for me was to switch my default Xcode from 8 to 9 using Xcode Select:

$ xcode-select --print-path

$ sudo xcode-select -switch /Applications/Xcode-9.2.app

Edit: Actually what seemed to help here was that Xcode 9.2 used the derived data from Xcode 8.3.3. Not a solution but at least it allows me to move forward with my work.


In my case, it was just the name of my target :

I renamed it like this : MyApp.something and the same issue appeared. But I saw in the build Settings window, my product module name has been changed like this MyApp-something. So, I removed the dot in my target name (MyAppSomething) and the issue was gone.


In my case, one of my testing targets was working but the other one was not. It was giving the above error with a missing library or whatever. I compared the settings for both of the testing targets and found that one was missing the configuration for "Test Host", so I copied that from the working test target and it fixed my broken test target!


Let's project P is importing custom library L, then you must add L into

P -> Build Phases -> Embed Frameworks -> +. That works for me.


None of the solutions worked for me. Restarting the phone fixed it. Strange but it worked.


Surprisingly enough, all i did was "Clean" my project (shift+cmd+K) and it worked. Did seem to be related to the certificate though.


The above solutions did not work for me. I fix the issue by the following steps:

  1. I had to go to the phone (Settings > Profile) and delete the profiles that were in the phone(including all the apps associated with those profile/provisions).
  2. After that, make sure that you download the apple provisions in xcode. Go to xcode settings > account and sign in into your apple developer account.

This error message can also be caused when upgrading Xcode (and subsequently to a new version of Swift) and your project uses a framework built/compiled with an older/previous version of Swift.

In this case rebuilding the framework and re-adding it will fix the problem.


To add on to the Enterprise distribution cert solution: you can open Keychain and inspect the cert. If there is any red text saying the trust chain can't be verified or it being revoked, it WILL NOT WORK! On my computer, our distribution cert was showing as revoked even though the web portal showed it as still valid. We got a new distribution cert, which was green (valid) in Keychain, and this solved the issue.



You have to set the Runpath Search Paths to @executable_path/Frameworks as showed in the following screenshot of Build Settings:

If you have any embedded frameworks made in Swift, than you can set to YES the Build Options Embedded Content Contains Swift Code.