Search code examples
xcodecocoapodsafnetworkingalamofirepodfile

Setting up a Framework on macOS Command Line apps - Reason: image not found


I have been wrestling with this for weeks now. Why does the following macOS setup give an Alamofire linker error ?

Steps to recreate linker error:

  • Create new macOS Command Line app
  • Run pod init from Terminal Update
  • Create the following podfile:

    platform :osx, ’10.10’ target 'testMacOS' do use_frameworks! pod 'Alamofire', '~> 4.0' end

Run pod install. Open and Build workspace

Error: dyld: Library not loaded: @rpath/Alamofire.framework/Versions/A/Alamofire Reason: image not found

AT THIS POINT, this error made sense. You needed to go to the Target's / General / Linked Frameworks and Libraries. Then add Alamofire. Now Alamofire was inside the workspace's Framework directory.

Build and run. Same error. Why?


Solution

  • Commandline tools do indeed "support" Frameworks, but not in the way Application bundles do. You need to put the referenced frameworks in the @rpath which in practice is ~/Library/Frameworks/ or /Library/Frameworks/