ios rpath - iOS app with framework crashed on device, dyld: Library not loaded, Xcode 6 Beta

10 Answers

In the target's General tab, there is an Embedded Binaries field. When you add the framework there the crash is resolved.

Reference is here on Apple Developer Forums.

awscore swiftyjson

This crash has been a blocking issue, basically I used following steps to reproduce the issue:

  • Create a Cocoa Touch Framework project
  • Add a swift file and a class Dog
  • Build framework for device
  • Create a Single View application in Swift
  • Import framework into app project
  • Instantiate swift class from the framework in ViewController
  • Build and run app on device

The app immediate crashed upon launching, here is console log:

dyld: Library not loaded: @rpath/FrameworkTest03.framework/FrameworkTest03
  Referenced from: /var/mobile/Applications/FA6BAAC8-1AAD-49B4-8326-F30F66458CB6/
  Reason: image not found

I have tried to build on iOS 7.1 and 8.0 devices, they both have the same crash. However I can build app and run on simulator fine. Also I am aware that I can change the framework to from Required to Optional in Link Binary With Libraries, but it did not completely resolve the problem, the app crashed when I create an instance of Dog. The behavior is different on device and simulator, I suspect that we can't distribute framework for device using beta version of Xcode. Can anyone shed light on this?

I received this same error while attempting to manually add my created framework into my project. Just dragging the framework into your project isn't going to be good enough. That is like being in the same ballpark but not being able to find your kids. It took me some trial and error to get it to work properly but following these steps did it for me.

1) Create your framework

  • Develop your framework.
  • Once your development is complete, COMMAND+B build your framework and ensure you receive "Build Succeeded".

2) Access your framework

  • Once your framework project successfully builds it will then be ready for you to access in your Products folder in your project.

  • Right click on your .framework and select "Show in Finder".

3) Place framework in your project

  • Drag and drop the .framework from your Finder window to your app project's "Framework" folder.

4) Configure app project for framework

  • Select the top level in your project

  • Choose your target

  • Go to "Build Phases", then "Link Binary with Libraries", and ensure that your framework is included with optional selected.

  • Still in "Build Phases", go to the upper left and select the + button. In the drop down choose "New Copy Files Phase".

  • Scroll down to the new "Copy Files" section and ensure that you set Destination to "Frameworks". Leave the subpath empty. Then click the + button at the bottom left.

  • You will be presented with your project hierarchy. Scroll down to the "Frameworks" folder that you added the framework to in step 3, or search for it in the search bar at the top. Select your framework and click "Add".

  • Ensure that your framework is included with "Code Sign On Copy" selected.

5) Clean, then run your project


I created a framework using Swift3/Xcode 8.1 and was consuming it in an Objective-C/Xcode 8.1 project. To fix this issue i had to enable Always Embed Swift Standard Libraries option under Build Options.

Have a look at this screenshot:

Hope that helps!

Add the framework in Embedded Binaries

Then Clean and Build.

My environment: Cocos2d 2.0, Box2d, Objective C

In addition to doing the other answers above I finally went to the General tab and made WatchKit Optional.

Surprisingly, not all of the necessary pieces are documented here, at least for Xcode 8.

My case was a custom-built framework as part of the same workspace. It turns out it was being built incorrectly. Based on jeremyhu's last response to this thread:

I had to set Dynamic Library Install Name Base (DYLIB_INSTALL_NAME_BASE) under Build Settings of the Framework and then rebuild it. It was incorrectly set to $(LOCAL_LIBRARY_DIR) and I had to change it to @rpath.

So in the link processing stage, it was instructing the host App to dynamically load it at runtime from /Library/Frameworks/fw.Framework/fw (as in, the root of the filesystem) rather than path-to-App/Frameworks/fw.Framework/fw

Regarding all the other settings: it does have to be in 3 places in Build Phases, but these are all set at once when you just add it to the Embedded Binaries setting of the General tab of the hosting App.

I did not have to set up an extra Copy Files phase, which seems intuitively redundant with respect to the embedding stage anyway. By checking the tail end of the build transcript we can assure that that's not necessary.

PBXCp /Users/xyz/Library/Developer/Xcode/DerivedData/MyApp-cbcnqafhywqkjufwsvbzckecmjjs/Build/Products/Debug-iphoneos/MyFramework.framework

[Many verbose lines removed, but it's clear from the simplified transcript in the Xcode UI.]

I still have no idea why Xcode set the DYLIB_INSTALL_NAME_BASE value incorrectly on me.

After trying all the methods available on internet and my own trial and error tricks 100 times. Finally I was able to solve it. – Apeksha Sahu 6 mins ago
Goto iTunes in Mac --> accounts-->Authorize this computer – Apeksha Sahu 5 mins ago
second step.... Goto developer in settings in iPad and iPhone and reindex with identifiers and clear trust computers everything. It worked for me........ ....... After reinstalling Mac OSHigh seria 10.13.15 version from Mac OS seirra beta latest version, to reinstalling Xcode latest version, after updating all certificates. etc etc etc... as many methods as you can think I did. –

  1. Go to file in xcode -> Workspace settings
  2. Click the arrow next to which appears /Users/apple/Library/Developer/Xcode/DerivedData
  3. Select the Derived data and move it to Trash.
  4. Quite the xcode and reopen it.
  5. Clean the project and run again.

Above steps resolved my issuses.


ios crash swift xcode6