Xcode: ld: library not found for -lAFNetworking

2019-03-11 16:23发布

Because of this one reason, build always fails...Any ideas about what I could try?

Because of this one reason, build always fails...Any ideas about what I could try?

EDIT: the solution is to open the xcworkspace instead of the xcproject!

12条回答
Juvenile、少年°
2楼-- · 2019-03-11 16:48

Use the xcworkspace to build instead of the xcproject?

This usually happens when using Cocoapods and you are building from the xcproject which doesn't know about the cocoapod libraries.

查看更多
劫难
3楼-- · 2019-03-11 16:49

I have in project->TARGETS->Build Phases ->Link Binary With Libraries one "extra" framework that remains from recent project. Delate it and all run smoothly

查看更多
Viruses.
4楼-- · 2019-03-11 16:51

I encountered this error when I downloaded some code from github. I tried to build .xcodeproj file but it failed giving the library not found error. I then opened .xcworkspace file and build that file first by clicking Product -> Build for -> Running. The workspace file built fine with no errors. Then in workspace file I changed scheme to the xcode project I was trying to build, and clicked Product -> Run. The app got built and ran with no errors.

查看更多
Evening l夕情丶
5楼-- · 2019-03-11 16:54

I Had this Issue several Times with PODS Libraries.

Here is something you can Try:

  1. Run pod cache clean --all and pod install again.

  2. Check your Header Search Paths and Library Search Paths, Remove all entries and place $(PROJECT_DIR) in recursive mode and $(inherited) as a Second Entry

  3. Go to your target Build Settings -> Other linker flags -> double click . Add $(inherited) to a new line.

查看更多
闹够了就滚
6楼-- · 2019-03-11 16:55

Make sure Build Active Architecture Only is set to NO in the Pods project settings.

查看更多
Viruses.
7楼-- · 2019-03-11 16:55

I had this issue while using fastlane with a ReactNative project. I had added a dependency that required cocoapods.

My Fastfile looked like this:

...
gym(
  scheme: "AppName",
  project: "./ios/AppName.xcodeproj"
)
....

And had to change it to the workspace like this:

...
gym(
  scheme: "AppName",
  workspace: "./ios/AppName.xcworkspace"
)
...
查看更多
登录 后发表回答