ld: library not found for -lAFNetworking xcode

18,958

Solution 1

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.

Solution 2

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

green box == .xcworkspace project

Solution 3

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

Solution 4

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

Solution 5

please try to install COCOAPOD app in your mac.

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

Share:
18,958
c00der
Author by

c00der

Updated on July 27, 2022

Comments

  • c00der
    c00der almost 2 years

    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
    c00der over 7 years
    with the help of Albert.Qing's answer at stackoverflow.com/questions/12002905/…, the problem was resolved. Thanks
  • c00der
    c00der over 7 years
    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?
  • little
    little over 7 years
    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 - guides.cocoapods.org/using/pod-install-vs-update.html
  • c00der
    c00der over 7 years
    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.
  • Arvind K.
    Arvind K. almost 3 years
    If the project uses CocoaPods be aware to always open the .xcworkspace file instead of the .xcodeproj file