Dyld: 库未加载:@rpath with iOS8

我正在用 Xcode6和 iOS8创建一个 iOS 框架。当我链接到一个 iOS 应用程序,并尝试在设备上运行它,我得到这个错误

dyld: Library not loaded: @rpath/FrameworkName.framework/FrameworkName
Referenced from: /private/var/mobile/Containers/Bundle/Application/0F2C2461-A68B-4ABA-A604-B88E6E9D1BB1/AppName.app/AppName
Reason: image not found

框架的“ Runpath Search Path”构建设置默认设置为

'@executable_path/Frameworks', '@loader_path/Frameworks'

我找不到任何与此相关的文件。这是 Xcode6引入的一些新东西,我希望它只是简单地将框架包含到任何需要它的应用程序中。

71229 次浏览

To make this work

  1. In the framework project settings change the install directory from '/Library/Frameworks' to '@executable_path/../Frameworks'

  2. In the project that includes this framework, add a copy files phase and copy this framework to the 'Frameworks' folder. Once you do this ensure that this framework is listed under the 'Embedded Binaries' section.

For me it was because of the SSL issue, I had set my developer, distribution certificates on my Mac(Keychain) to 'Always Trust' for one of my other project. I had to change them back to 'Use System Defaults'. it was working for me then!!

Issue resolved using this answer. According to @vladof81:

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.

In addition to the above solutions, recheck the paths of frameworks included in your application under

Build Settings --> Search Paths --> Framework Search Paths

I was getting this error on a library installed through CocoaPods. Cleaning the build folder (cmd + option + shift + k) and then doing a clean (cmd + shift + k) was what ended up resolving this issue for me.

I also had same kind of problem where I was not able to launch the app & app was crashing with above message :

dyld: Library not loaded: @rpath/FrameworkName.framework/FrameworkName Referenced from: /private/var/mobile/Containers/Bundle/Application/xxxxxxxxxxxxxxxxxxx

Reason: image not found

Here is my approach that helped me to resolve this error:

1.Please delete your app from device, Clean the build and and rebuild and run on the device.

2.If above steps does not help you, then please check for below settings :
From "TARGET">"Build Settings">"Runpath Search Paths" & then check for values "$(inherited)" & "@executable_path/Frameworks", Feel free to add incase they don't exist.

Build your app and run it on device

Check if you can find framework in context under :

Build Phases > Embed Frameworks >

If not just add that framework in "Embed Frameworks" after adding that framework in your project directory's "Frameworks" section.
enter image description here

When non of those solution works:

  1. (Optional) Get a clear knowledge from here on different search path type
  2. Make sure that your .framework file paths are added in Build Settings -> Framework Search Paths. You can keep all framework files somewhere in App/libs/ and add this folder and enable recursively.
  3. Make sure that your .a files paths are added in Build Settings -> Library Search Paths.

enter image description here

If you are using Carthage

Run carthage update on terminal

Go to Project Settings -> Build Phases -> Carthage Copy Frameworks

Add line in Inputs files: $(SRCROOT)/Carthage/Build/iOS/YOURLIBRARY.framework

Add this line to Output files: $(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/YOURLIBRARY.framework

I installed third party libraries using Cocoapods. Got the same error, tried everything but finally realised I havent had use_frameworks! in my pod file.

So removed the currently installed library, added use_frameworks! line in pod file, reinstalled the libraries and all worked for me.

Made the library which shows not loaded changed from required to optional in Linked binaries and frameworks. It is working perfectly now

I also had same kind of problem where I was not able to launch the app & app was crashing with above message :

dyld: Library not loaded: @rpath/FrameworkName.framework/FrameworkName Referenced from: /private/var/mobile/Containers/Bundle/Application/xxxxxxxxxxxxxxxxxxx

Reason: image not found

Here is my approach that helped me to resolve this error:

  1. From General Tab

Frameworks, Libraries, and Embedded Content

  • add the framework and make sure to make it Embed & Sign

General Tab

  1. From Build Phases

Dependences

  • add the framework to it

Build Phases

The way tested by me is well.

In "Linked Binary With Libraries" change the missing framework to "Embedded Framework".

Because, "Do not Embedded" do not copy to the App, but Embedded Framework will copy into it.