Andre M
Andre M

Reputation: 7536

Cocoapods dependency and "Library not loaded ... image not found"

I am building a command line project, via XCode 7.2.1, that uses Cocoapods for its dependencies. The framework it depends on is generated in the 'DerivedData' folder and the main project builds, but when I come to run the application I get the error:

dyld: Library not loaded: @rpath/Alamofire.framework/Versions/A/Alamofire
  Referenced from: /Users/myuser/Library/Developer/Xcode/DerivedData/myproject-aidrwlylcmipvrckcfcztpjjkxab/Build/Products/Debug/myproject
  Reason: image not found

Files tree under versions/A of the framework:

_CodeSignature
   CodeDirectory
   CodeRequirements
   CodeResources
   CodeSignature
Frameworks
Headers
   Pods-avsubtitleswriter-umbrella.h
Modules
   module.modulemap
Pods_avsubtitleswriter
Resources
   Info.plist

Have tried with Cocoapods 0.39.0 and 1.0.0beta, and in XCode I am using the .xcworkspace.

Looking at Pods project, under products I see Alamofire.framework in red and Pods_myproject.framework in black, in case that indicates anything?

Additionally, do we need to sign libraries we depend on?

Upvotes: 4

Views: 5543

Answers (2)

Andre M
Andre M

Reputation: 7536

Looks like the issue was due to the default setting of "per-configuration build products path" which was $PODS_SHARED_BUILD_DIR/Alamofire, which was conflicting where the project thought the framework should be (the framework was pointing to another path). Changing the value to simply be $PODS_SHARED_BUILD_DIR solved the build issue, since the two locations ended up being the same.

Before this I had not done anything else than pod install and a build of the workspace.

Note, once I solved that issue I did need to add the following path to the "runtime search paths":

/System/Library/CoreServices/MRT.app/Contents/Frameworks/

Appears to be covered by issue #4963

Upvotes: 4

Hugo Tunius
Hugo Tunius

Reputation: 2879

Command line apps differ from regular OSX .app or iOS apps in that the linking of frameworks needs to be specified more explicitly. This is done by dynamically linking frameworks via run-path.

Have a look at this issue

Also here's some more info from Apple.

Upvotes: 0

Related Questions