Cocoapods dependency and “Library not loaded … image not found”

旧街凉风 提交于 2019-12-12 15:43:45

问题


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?


回答1:


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




回答2:


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.



来源:https://stackoverflow.com/questions/35732773/cocoapods-dependency-and-library-not-loaded-image-not-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!