Library not loaded- Alamofire

青春壹個敷衍的年華 提交于 2019-12-24 03:10:59

问题


I have been plagued by a bug for hours. I am building a framework using Alamofire and am testing it in an iOS project. Whenever I run the project, I get this error:

dyld: Library not loaded: @rpath/Alamofire.framework/Alamofire Referenced from: /Users/theodorestrauss/Library/Developer/Xcode/DerivedData/TGClient-ecnnvvvxipoufihfghkpxlfccyoc/Build/Products/Debug-iphonesimulator/TGClient.framework/TGClient Reason: image not found

I have scoured the web looking at GitHub issues, Stack articles, and more. I've cleaned, deleted Derived Data, added and deleted frameworks from embedded binaries, etc.

For anyone out there, this is not a duplicate. All other questions and answers are outdated.

If anyone can help, I'd immensely appreciate it. Thanks so much in advance. Cheers,

Theo


回答1:


This is what I do when I have this problem (and it really works!):

  1. Remove Alamofire framework from target/embedded libraries and target/linked frameworks and libraries by highlighting it and clicking the minus sign. (click on your project name in the upper left corner if you don't see these areas in the center of your screen).

  2. Perform a product clean (Shift-Cmd-K).

  3. In Embedded Binaries section, click on the + sign. Add Alamofire. (or drag the Alamofire icon from the left column into this section and drop it there)

  4. Xcode should fix everything, and it should now load onto the device properly.




回答2:


I was getting this error while using Alamofire 4.5 + carthage, I added the framework as Linked Libraries in the build phase, the app was crashing on start. In XCode 9.1 I couldn't find the option of Embedded framework, so I added a Run Script to copy framework from Carthage and it started working. So basically this

  1. Add the framework to the build phases as you normally do.
  2. Add the below Run Script

/usr/local/bin/carthage copy-frameworks

$(SRCROOT)/Carthage/Build/iOS/Alamofire.framework




回答3:


Can you please clear derived data once and build the project again.

Here is how to clear derived data. Open the terminal and simply hit this command.

rm -rf ~/Library/Developer/Xcode/DerivedData



回答4:


Make sure your build settings > Runpath search paths have be

• @executable_path/Frameworks
• $(inherited)

Also in your framework search path below entry is there

"$PODS_CONFIGURATION_BUILD_DIR/Alamofire"


来源:https://stackoverflow.com/questions/45152965/library-not-loaded-alamofire

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