109

I have just updated to Xcode 7 and swift 2 and finished fixing the errors that come with the transition. I finally got the project to build, but after the launch screen I get an error saying:

dyld: Library not loaded: @rpath/libswiftAVFoundation.dylib Referenced from: /var/mobile/Containers/Bundle/Application/...
Reason: no suitable image found. Did find: /private/var/mobile/Containers/Bundle/Application/.../Frameworks/libswiftAVFoundation.dylib: mmap() errno=1 validating first page of '/private/var/mobile/Containers/Bundle/Application/.../Frameworks/libswiftAVFoundation.dylib'

I have seen this error before but with other frameworks, and can't solve my issue. Is there a way to bypass this by adding my framework somewhere?

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
coracora
  • 1,337
  • 3
  • 9
  • 12
  • 7
    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:58
  • Possible duplicate of [Reason: no suitable image found.](http://stackoverflow.com/questions/32730312/reason-no-suitable-image-found) – trojanfoe Nov 03 '15 at 15:38
  • Ok so after having this issue multiple times, this is the only thing that has worked for me. Not sure why the other solutions didn't, but I followed the instructions here: https://stackoverflow.com/a/32730393/3474814 – coracora Sep 24 '15 at 22:48
  • Just clean the project and run again – onmyway133 Nov 06 '18 at 09:37

12 Answers12

192

Try to do clean, build and then run the project. Worked for me.

mikebertiean
  • 3,611
  • 4
  • 20
  • 29
  • 2
    Didn't work for me, for a similar problem with Swifty.json :( – Hatchmaster J Mar 09 '16 at 09:36
  • 4
    Worked for me. I had this problem since my certificate has been revoked. Now its OK. – Adam Studenic Apr 27 '16 at 10:33
  • 1
    Thank you so much for the help! I have just renewed my iOS development certificate and I was facing this frustrating error. It's incredible how xcode's errors are NOT intuitive to inspect... – Gabcvit Apr 17 '18 at 07:57
  • 1
    After spending a few hours trying different solutions in Xcode 10.2, none worked. But run the project in Xcode 10.1 and it worked (Always Embed Swift Standard Libraries to Yes). In my search for the solution I read someone saying that the problem was in the Swift Compiler, maybe in 10.2 there is a problem. – Carlos Parada Apr 11 '19 at 22:09
55

In Xcode 8 updating the Build Setting

Always Embed Swift Standard Libraries to Yes

worked for me.

JulianM
  • 2,540
  • 18
  • 13
  • I think this is a possible correct answer. From Apple docs. "If you are building an app that does not use Swift but embeds content such as a framework that does, Xcode will not include these libraries in your app. " Reference: https://developer.apple.com/library/content/qa/qa1881/_index.html – David Pettigrew Feb 16 '17 at 20:00
  • 1
    I'm trying to convert an old objective-C project (partly) to swift. Setting "always embed swift standard libraries" to yes fixed it for me. – Darrell Root Feb 24 '19 at 18:28
30

None of the above solutions worked for me. In the end the problem was my signing certificate's trust settings. They were set to "Always Trust" which seemed to cause this issue. Switching it back "Use System Defaults" fixed it for me.

In my case I originally changed the certs trust settings because I had issues building remotely. I was able to fix both issues by switching the trust settings to "Use System Defaults" globally and "Always Allow" for SSL.

Hope this helps someone.

desmond
  • 560
  • 7
  • 8
25

When the answer marked as correct didn't work for me I added the following to "Build Settings > Linking > Runpath Search Paths":

@executable_path/Frameworks
ArtisanC
  • 423
  • 1
  • 5
  • 9
7

I got this problem when trying to remove my provisioning profile and app certificate. Then all my swift projects have this problem. After almost an hour i found that just simply clean the project by:

Click on Product -> Clean (or CMD-Shift-K)

And the projects will run normally.

nhoxbypass
  • 9,695
  • 11
  • 48
  • 71
6

Similar question below, the answers there may offer some help. dyld: Library not loaded: @rpath/libswiftCore.dylib

For me the only solution that worked was as @morten-holmgaard suggested in his comment.

I have also tried to change the "Embedded Content Contains Swift Code" flag to true in build settings, but it had no effect.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Bruno Coelho
  • 926
  • 13
  • 25
2

Changing the Build Settings -> "Embedded Content Contains Swift Code" flag to true/yes worked for me.

Brian Ogden
  • 18,439
  • 10
  • 97
  • 176
2

For the framework I am using on OSX (MailCore2) I had to set my target's

"Build Settings > Linking > Runpath Search Paths" to @loader_path

a solution I found here:

http://www.dribin.org/dave/blog/archives/2009/11/15/rpath/

ghr
  • 505
  • 4
  • 8
  • The article was helpful, thanks! None of the other solutions here did it for me, but I was able to finally get it working by adding `@rpath` to the `Runpath Search Paths` linker setting. – caughtinflux Aug 11 '17 at 04:19
2

I ran into this issue with Xcode 9. This did the trick for me:

Project > Build Settings > Swift Compiler - Search Path: Setting "Import Paths" to $(PROJECT_DIR) (recursive)

Cœur
  • 37,241
  • 25
  • 195
  • 267
ggs
  • 140
  • 1
  • 2
  • 11
1

There are two solutions for this:

Solution 1:

  1. Quit Xcode (cmd + Q)
  2. Open and Clean Project (cmd + shift + k)
  3. Now, run the project which should work correctly

Solution 2:

The console log itself states that dynamic link editor (dyld) is not able to load library. In order to fix this use below steps :

  1. Select Project -> Build settings ->
  2. Go to Build options tab -> Select ‘Always Embed Swift Standard Libraries’ to ‘Yes
  3. Now, run the project which should work correctly

Screenshot with steps

Cœur
  • 37,241
  • 25
  • 195
  • 267
Jayprakash Dubey
  • 35,723
  • 18
  • 170
  • 177
0

This can be a problem with certificates. Go to the Apple developer member center and make sure you have "Organizational Unit" set in your distribution profile.

Also take a look in the logs for the text deny-mmap, this will probably help you further.

I ran into this problem with a Xamarin application for the Apple Watch. The main application and the Mono framework were signed and working, but the Watchkit Extension did not load due to the dyld error.

Windel
  • 499
  • 4
  • 11
0

I encountered a similar error and fixed it by bumping my minimum deployment target up to iOS 13. (I'm on Xcode 14.3.1 and opened a very old project that had its minimum deployment target still set to 10.0)

charmingToad
  • 1,597
  • 11
  • 18