4

I am aware that there are at least 5 different question on SO with exact same description however I have tried every single answer there without any avail.

For last 12 days I am unable resolve the following error:

dyld: Library not loaded: @rpath/libswiftCore.dylib
  Referenced from: /private/var/mobile/Containers/Bundle/Application/D385AC46-BAB1-4FEB-8C08-7F78D095605E/tes.app/tes
  Reason: no suitable image found.  Did find:
    /private/var/mobile/Containers/Bundle/Application/D385AC46-BAB1-4FEB-8C08-7F78D095605E/tes.app/Frameworks/libswiftCore.dylib: mmap() error 1 at address=0x1000B0000, size=0x0018C000 segment=__TEXT in Segment::map() mapping /private/var/mobile/Containers/Bundle/Application/D385AC46-BAB1-4FEB-8C08-7F78D095605E/tes.app/Frameworks/libswiftCore.dylib
  • I have revoked the certificates almost 15 times, verified that their have a subject line with OU etc.
  • I have sent the embedded swift code flag to Yes
  • I have set Run path search path to appropriate value.

Is there anyone else who can help ? Looks like I wasted $99 on Apple's no-language.

Aryan R
  • 233
  • 3
  • 10
  • 1
    Did you try only with your own application? You should download any sample application from the web and see if you can run that one on your device. And you say 'unable to run Swift iOS app', does that mean you don't have the issue with Objective-C? – Wouter Apr 08 '15 at 11:29
  • 1
    And please try a complete clean build: Product->Clean, Product->(Alt key) Clean Build Folder, Window->Organizer->Delete derived data. Then build again – zisoft Apr 08 '15 at 12:00
  • Were you able to run the app on the device before? I would always suggest, that if things don't work and seem not to be fixable, to de- & reinstall Xcode, that fixes a lot of problems. Try that :) – LinusGeffarth Apr 08 '15 at 19:29
  • I have no issues running Objective-C projects. Only swift code does not run because it is not getting signed properly. I have tried the default "create new project" feature and I am not running anything other than hello world. It runs perfectly on the simulator. cc: @Wouter – Aryan R Apr 08 '15 at 20:09
  • @LinusG. I have uninstalled Xcode and installed at least 2 different versions. I have also deleted XCode files, Caches, derived data several times. – Aryan R Apr 08 '15 at 20:10

4 Answers4

1

I eventually found the answer. I had to delete all the certificates in the chain Keychain Manager.

Aryan R
  • 233
  • 3
  • 10
0

Did you check the "Embedded Content Contains Swift Code" setting in the project settings?

I found it here: dyld: Library not loaded: @rpath/libswiftCore.dylib

Community
  • 1
  • 1
Bryan Cimo
  • 1,268
  • 1
  • 19
  • 34
  • Yes. I have dont that and everything else mentioned in that answer. – Aryan R Apr 15 '15 at 19:12
  • So you can run apps on a device when you have code that's written in objective-c, but not Swift? When you look at the device in the Devices window does it show up OK there? Also, can you make an archive? Check this out: https://developer.apple.com/library/ios/documentation/IDEs/Conceptual/AppDistributionGuide/LaunchingYourApponDevices/LaunchingYourApponDevices.html#//apple_ref/doc/uid/TP40012582-CH27-SW1 – Bryan Cimo Apr 16 '15 at 06:24
  • Yes I can make an archive. The devices window shows my device. – Aryan R Apr 18 '15 at 09:08
0

For what it's worth, I do not have a detail reasoning backing my solution, but just a theory.

I too was in you situation, trying failed solution after solution, only to continue running in circles hoping that a magic update from Apple would solve the issue. I've gone through the revoking of certificates, re-installing Xcode, checking Embedded Content Contains Swift Code to 'Yes', and making sure my runpath had
@executable_path/Frameworks.

One problem I frequently and increasingly run into problems with are related to Apple increasing their file access security. This appears to be more of a problem when more than one profile are associated with a computer.

I know it's easy to ignore a lot of the jargon from error messages, but what tipped me off to the issue was the following error when the file was actually found

mmap() error

What I think is happening is while attempting to remap libswiftCore.dylib 'Reason: no suitable image found. Did find:' the mapping from the expected file to the actual file location, a file permission restriction is being enforced that is not properly handled, therefore causing the app to crash.

What I did? Force authentication for all my certificates related to iOS development. This action being, going to my keychain access and clicking on the certificates private key's and forcing my access control to 'confirm before allowing access', and setting my Trust level of the Certificates to system defaults. The result of this caused my project build to ask me to authenticate 50-60+ times, however, this was a lot less painful then the hours spent debugging.

This is why I said my solution does not have a specific detailed answer, as I pretty much used a catch all approach. Since I am now only recently coming to this solution, I have not done any additional testing to determine what specifically was causing the error, or if changing the access control back to allowed from Xcode will work going forward.

This is what worked for me, and from your description I believe will work for you as well.

John Saunders
  • 160,644
  • 26
  • 247
  • 397
tha2nddunn
  • 46
  • 2
0

I had to delete all apple certificates and regenerate my development/distribution certificate.

I also added the Apple WWDRCA certificate and deleted the expired ones using following steps:

  1. https://developer.apple.com/certificationauthority/AppleWWDRCA.cer.
  2. Double-click to install to Keychain. Then in Keychain, Select View -> "Show Expired Certificates" in Keychain app.
  3. It will list all the expired certificates. Delete "Apple Worldwide Developer Relations Certificate Authority certificates" from "login" tab
  4. And also delete it from "System" tab.
megha
  • 473
  • 5
  • 18