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

MacosAvfoundationXcode7Dyld

Macos Problem Overview


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?

Macos Solutions


Solution 1 - Macos

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

Solution 2 - Macos

In Xcode 8 updating the Build Setting

Always Embed Swift Standard Libraries to Yes

worked for me.

Solution 3 - Macos

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.

Solution 4 - Macos

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

Solution 5 - Macos

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.

Solution 6 - Macos

Similar question below, the answers there may offer some help. https://stackoverflow.com/questions/26024100/dyld-library-not-loaded-rpath-libswiftcore-dylib/33153733

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.

Solution 7 - Macos

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

Solution 8 - Macos

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/

Solution 9 - Macos

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)

Solution 10 - Macos

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

Solution 11 - Macos

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestioncoracoraView Question on Stackoverflow
Solution 1 - MacosmikebertieanView Answer on Stackoverflow
Solution 2 - MacosJulianMView Answer on Stackoverflow
Solution 3 - MacosdesmondView Answer on Stackoverflow
Solution 4 - MacosArtisanCView Answer on Stackoverflow
Solution 5 - MacosnhoxbypassView Answer on Stackoverflow
Solution 6 - MacosBruno CoelhoView Answer on Stackoverflow
Solution 7 - MacosBrian OgdenView Answer on Stackoverflow
Solution 8 - MacosghrView Answer on Stackoverflow
Solution 9 - MacosggsView Answer on Stackoverflow
Solution 10 - MacosJayprakash DubeyView Answer on Stackoverflow
Solution 11 - MacosWindelView Answer on Stackoverflow