Search code examples
iosobjective-ciphonecocoalumberjack

iOS: dyld: Library not loaded: @rpath/CocoaLumberjack.framework/CocoaLumberjack


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.


Solution

  • Well, the difference is simple:

    Whenever you run your app in simulator it can access any other build products in the same build folder, e.g., frameworks. That's why you do not experience this problem in simulator. On your iOS device that is different story because Xcode only copies the actual app bundle to your device. So in order to make it work you need to add CocoaLumberjack.framework to the Embed Frameworks build phase. This will copy the framework into the Frameworks subfolder in the app bundle so that your app binary can find it.

    enter image description here

    If you do not have the Embed Frameworks build phase you can either add a New Copy Files Build Phase via the add button in the top left of the build phases tab and then select Frameworks as destination. The other option is to select the General tab, scroll down and then add your framework under the Embedded Binaries section.