library not found for -lPods-AFNetworking

2019-02-08 06:40发布

问题:

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:

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



回答2:

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.


回答3:

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



回答4:

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!



回答5:

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.

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.



回答6:

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...



回答7:

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.