1

I'm trying to implement CocoaLumberjack as framework and it works fine on the simulator but when try to use it on my iPhone I'm getting this error:

dyld: Library not loaded: @rpath/CocoaLumberjack.framework/CocoaLumberjack
  Referenced from: /var/containers/Bundle/Application/3EF12D55/myApp.app/CocoaLumberjackSample
  Reason: image not found

Any of you knows why the difference between the simulator and the device?

I'll really appreciate your help.

4

1 回答 1

6

好吧,区别很简单:

每当您在模拟器中运行您的应用程序时,它都可以访问同一构建文件夹中的任何其他构建产品,例如框架。这就是您在模拟器中没有遇到此问题的原因。在您的 iOS 设备上,情况就不同了,因为 Xcode 只会将实际的应用程序包复制到您的设备上。因此,为了使其工作,您需要将 CocoaLumberjack.framework 添加到Embed Frameworks构建阶段。这会将框架复制到Frameworks应用程序包的子文件夹中,以便您的应用程序二进制文件可以找到它。

在此处输入图像描述

如果您没有Embed Frameworks构建阶段,您可以New Copy Files Build Phase通过构建阶段选项卡左上角的添加按钮添加一个,然后选择Frameworks作为目标。另一个选项是选择“常规”选项卡,向下滚动,然后在该Embedded Binaries部分下添加您的框架。

于 2017-04-10T19:52:51.577 回答