18

I am getting the following error when using AFNetworking:

''library not found for -lPods-AFNetworking''
"linker command failed with exit code 1 (use -v to see invocation)."

I checked for all missing frameworks,and they are all present .Additionally this project works for other people(we pulled it from github) and I'm the only person for whom it does not work.(its a joint project)

We all use Xcode 6.2. I do not understand what could be wrong or what went missing. I tried pulling using the command line,sourceTree and even from Xcode git source control.

I also tried different versions of Xcode. But all the other teamates are using Xcode 6.2, which I am using now.

It used to work before, it suddenly stopped working.

Any ideas are welcome,thank you!

Following is the detailed errors:

ld: warning: directory not found for option '-L/Users/ramapriyasridharan/Documents/Rama-3:06:2015-ios/Mapbox' ld: warning: directory not found for option '-L/Users/ramapriyasridharan/Documents/Rama-3:06:2015-ios/Pods/build/Debug-iphoneos' ld: library not found for -lPods-AFNetworking clang: error: linker command failed with exit code 1 (use -v to see invocation)

EDIT:

After opening the workspace file, I did not get the mach O linker error any more, but I am getting the following error:

Command /Volumes/Xcode 1/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/momc failed with exit code 1

I asked my team mates who said that it still works fine,so it is still a problem only on my computer!

1
  • I assume you use .xcworkspace file. Can you post your Other linker flags? Jun 2, 2015 at 16:26

7 Answers 7

36

Instead of opening the XCode project, you should open up the WorkSpace file.

5
  • I pulled from github using xcode,and it open up the project directories for me to see, is it wrong?
    – LoveMeow
    Jun 2, 2015 at 16:26
  • 1
    Not sure what you mean. Does the project have a workspace file? Close the xcode window and open the workspace file, clean and build.
    – some_id
    Jun 2, 2015 at 16:28
  • I did not get the mach O linker error! But I am getting a new one,which others are not getting,I have updated the question
    – LoveMeow
    Jun 2, 2015 at 16:39
  • 1
    from terminal go under project path and install pod , update pod , it will solve the linker problem . Jun 4, 2015 at 9:10
  • @Adnan thank you for your reply, It has fixed the AF-networking error,but it has sprouted a new one, it gives an error in one of the pod files themselves called GRMustache 6.8.3
    – LoveMeow
    Jun 4, 2015 at 12:03
24

I was facing the same problem and following solution worked for me:

  1. Go to project setting -> build setting -> other linker flag, and remove all flags that have -lpod or frameworks or related to pods. Don't remove the required flags (e.g. -ObjC, -licucore, -libxml2)
  2. Add a flag $(inherited) at the top.
  3. Clean the project and compile.
4
  • actually how did you got that, is there any suggestion from Pods that we should do it, or you just tried this as you supposed that it should work? Apr 12, 2016 at 15:16
  • 1
    I was searching the similar problem where the error was in different pod library. I found a solution from stack over flow post only and tried in my project and that worked. Therefore I summarised the solution and posted here because the problem was of similar kind. Apr 13, 2016 at 6:56
  • this made so much sense! changing -l"Pods-AFNetworking" to -l"AFNetworking" didn't help, this did. Thanks a lot
    – EarlySun
    Oct 31, 2016 at 23:22
  • oh man, I was unable to compile for one week after I started using user_frameworks! in my pod file, still don't know for what this was originaly set in our proyect, but thanks!
    – David
    Jun 8, 2017 at 15:49
9

I had the same error while migrating my project to iOS 9. I solved it by doing this:

  1. Navigate to the Build Settings tab for your project and search for "link".
  2. In the the Other Linker Flags section, remove -l"Pods-AFNetworking" and replace it with -l"AFNetworking"

See the screenshot linked here for more information:

http://i.stack.imgur.com/uG51T.png

5

I wanted to write an answer myself because two things together worked :

  1. AS @Helium3 mentioned, I had to open the workspace rather than the project file in the file explorer(projectname.xcworkspace file)(I actually have 2 and only 1 seems to work!)

  2. As @Muhammad Adnan mentioned in the comments, what worked was to install pod and update pod it solved the linker problems!!(Note: This should be done in the project directory,make sure cocoapods are installed first!!), in addition it gave me odd errors at first(after a second go),later it was alright!

Thank you guys!

2

It has been a while since this question but today I ran into a similar issue and how we solved it was by going to: Edit Scheme > Build

and making sure the option ´Find Implicit Dependencies´ is checked.

Screenshot scheme settings

I had it unchecked and after I updated CocoaPods to 1.0, I couldn´t find the dependencies in the Derived Data folder.

After that I could build it succesfully.

0
1

In iWatch App using Cocoa Pods AFNetworking i got the Same issue.

I Just Solved Issue ....

Just Follow this Step.

[1] Open your project's podfile by typing in terminal:

open -a Xcode Podfile

Check If you are Using AFNetworking than using

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'

pod 'AFNetworking', '~> 3.0'

copy and paste this between target 'iChat' do .... end

Like .....

target 'iChat' do
  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  # use_frameworks!

  # Pods for iChat

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'

pod 'AFNetworking', '~> 3.0'

end

and

[2] Then open your terminal again simply paste it.

pod install

Now open App.xcworkspace and Clear and Run You can see Error is Gone Now...

0

React native:

I forgot to install a new RN module after pulling changes. So don't forget to npm i or yarn before building with react-native.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.