Xcode: ld: library not found for -lAFNetworking
Asked Answered
T

12

46

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!

Trella answered 18/9, 2015 at 4:25 Comment(3)
May be it’s help. Follow link https://mcmap.net/q/372927/-cocoapods-and-xcode-ld-library-not-found-for-lafnetworkingKhz
Please click the scheme button and then -> GENERIC IOS DEVICE. If you choose that option then will it build? If so, that helps influence the answer.Bigeye
thanks i solved the problem!Trella
L
93

Might be you are opening .xcodeproj file after installing pods. Close the project and open .xcworkspace file.

Legate answered 20/6, 2017 at 4:23 Comment(3)
and if I don't use cocoa pods?Edva
Such a silly mistake. :( Thanks for saving our lives. _/\_Saba
I would have never known this if it wasn't for this comment. Thanks!!Ricciardi
K
22

Have the same issue.

What I did with the help of https://premium.wpmudev.org/forums/topic/anybody-solved-this-linker-command-failed-with-exit-code-1 and Adlair Cerecedo-Mendez

  1. Delete the "Pods" project on the left panel of Xcode.
  2. Close Xcode and delete this file in the finder too.
  3. Install pods again.
  4. Open Xcode and clean.
  5. Verify that the build option "Build Active Architecture Only" is set to "NO" for your project but also for your Pods project (selection with left panel).
  6. Click on your project Scheme (top, near the stop button) and "Manage Scheme".
  7. Check, select all your pods libraries and close.
  8. Then, for all libs, select them (scroll the list) and build manually for the selected architecture.

Every time you change your architecture (simulator, device or for archive(Generic iOS Device)) you must do the above step: namely, manually build each libraries by selecting them in your scroll list one by one, and only than build and run your main project.

Seems a bit WTF, but it is the only way I resolve this issue...

Keesee answered 15/12, 2015 at 10:44 Comment(3)
I think this needs to be the accepted answer. Thanks!Leibowitz
Step 7 and 8 solved my problem. Building the missing pod library. ThanksProudman
I couldn't see the "Pods" project but this was because I opened the xcodeproj file rather than the xcodeworkspace file. Otherwise, solved my problem, thanks.Rarely
L
18

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.

Ladoga answered 15/12, 2015 at 10:55 Comment(0)
O
13

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

Ourselves answered 31/5, 2016 at 20:33 Comment(2)
when you're doing a release it should be YES correct?Alfy
The release configuration should be NO so your app is built in all architectures, technically the configurations that will/can be installed in multiple types of devices need to be NO, like ad hoc builds to your team when they have iPads and iPhones, and definitely the App Store build needs to be NO. The other configurations, like debug, can be YES and that will also improve your build times.Ourselves
D
12

I'm thinking on two possibilities:

1) Install cocoapods-deintegrate project:

$ gem install cocoapods-deintegrate

Then run $ pod deintegrate, after that run $ pod install again. If it not works, then...

2) You can try open your Pods project and create new scheme for the target that you need, in this case for AFNetworking.

When the static library is created, then add it to your Frameworks references into your main project.

Hope that helps.

Dagmardagna answered 25/11, 2015 at 22:10 Comment(2)
This one saved me. After I upgrade Cocoapods to 1.0.1, I met very very hard time with Cocoapods.Lin
Doesn't work. This cause another annoying issue: gem(s) (Gem::MissingSpecError)Heritable
O
3

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

Onstage answered 21/11, 2017 at 14:41 Comment(0)
B
3

Had a similar issue ... took a while to realize that I had updated my app's "iOS Deployment Target" to iOS 9.0, but the Pods project's "iOS Deployment Target" was still iOS 8.0!!!

Booze answered 23/1, 2018 at 20:20 Comment(0)
K
2

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.

Kv answered 15/12, 2015 at 10:48 Comment(0)
I
2

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"
)
...
Inspan answered 30/3, 2017 at 21:12 Comment(0)
G
1

For me all this thing not help. Only delete in Build settings project.

enter image description here

Geopolitics answered 6/2, 2019 at 11:41 Comment(0)
A
0

open xcode, from the top left select the pod library that is being shown as not found.Use 'Command B' to build this pod, then again select your target scheme and run.

For me this fixed it.

Attis answered 22/11, 2017 at 11:46 Comment(0)
C
0

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.

Conjecture answered 9/8, 2018 at 13:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.