8

I am a total newbie to ios programming. Cloned a friends project. When trying to build (after resolving a lot of other errors), I get the following error:

ld: library not found for -lAFNetworking
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I checked the Pod file and searched for AFNetworking in the project, and it is there. Don't know what is going wrong.

c00der
  • 543
  • 1
  • 4
  • 20

6 Answers6

11

also make sure you are running the .xcworkspace project (white icon),not the .xcodeproj project (blue icon)

green box == .xcworkspace project

t.ios
  • 1,024
  • 12
  • 18
6

The error message indicates that the library was not found.

Make sure that:

  1. You see the AFNetworking in your Pods directory.
  2. Your Pods directory is in the search paths. Go to the project -> Build Settings -> Search for 'search paths' and make sure that your Pods directory is there. You can add it by adding "${PROJECT_DIR}/Pods" for example.
little
  • 2,927
  • 2
  • 25
  • 36
  • with the help of Albert.Qing's answer at http://stackoverflow.com/questions/12002905/ios-build-fails-with-cocoapods-cannot-find-header-files, the problem was resolved. Thanks – c00der Nov 07 '16 at 19:23
  • Hi, after doing that, I got another 20 errors apparently due to the AFnetworking version I was using. I changed it to version 2 on the Pod file and did pod install, now, again, I get the same error. What could be going wrong there? – c00der Nov 07 '16 at 19:28
  • Check if indeed the Pod install updated the AFNetworking package. When running pod install it should list the version installed and you can also find it in the Podfile.lock. See also this link - https://guides.cocoapods.org/using/pod-install-vs-update.html – little Nov 08 '16 at 06:10
  • Hi, yeah. It is installed. When I set the search paths, should it be for the project or the targets? To be safe, I set the search paths everywhere to be ${PODS_ROOT}; still no luck. – c00der Nov 08 '16 at 13:46
  • 1
    If the project uses CocoaPods be aware to always open the .xcworkspace file instead of the .xcodeproj file – Arvind K. Jul 17 '21 at 04:56
4

add $(inherited) flag to LIBRARY_SEARCH_PATHS at build settings in Xcode target.

Zero.D.Saber
  • 371
  • 2
  • 6
4

1.Remove Path from Other Linker flags 2.Clean the build 3.Run the code

msk_sureshkumar
  • 343
  • 4
  • 10
0

please try to install COCOAPOD app in your mac.

Try to re attached AFNetworking here is the link please follow the instruction

AFTAB MUHAMMED KHAN
  • 2,189
  • 3
  • 18
  • 24
-1

If you are using CocoaPods please check that you are opening .xcworkspace file not the .xcodeproj file. The difference lies in icon color. xcworkspace icon is white while xcodeproj is of blue color

Arvind K.
  • 1,184
  • 2
  • 13
  • 27