AFNetworking won't compile

那年仲夏 提交于 2019-12-03 06:41:39

I spent a couple of hours fighting with this exact same issue, going through all the Google hits I could find. Building for the device was working, but building for the simulator was not.

Here are the steps that finally solved the issue for me:

  1. Clear the XCode caches:

    rm -rf ~/Library/Developer/Xcode/DerivedData/
    
  2. Clear the CocoaPods caches and reinstall the dependencies:

    rm -rf "${HOME}/Library/Caches/CocoaPods"
    rm -rf "`pwd`/Pods/"
    pod update
    
  3. Finally go to the "Pods" project and set the Build Active Architectures Only to No also for the "Debug" configuration.

I would suggest you to add the $(inherited) flag into the "Build settings".

  • Tap on the blue project icon
  • Select "Build settings" tab
  • Under "Linking" you'll find a setting called "Other Linker Flags"
  • add $(inherited) into the textfield

I had the same issue, when I had -lc++ already set on Other linker flags for cpp library usage purpose.
I added these two flags -ObjC -l"AFNetworking" on Other linker flags, which worked and compiled successfully. These are the two flags -ObjC and -l"AFNetworking". You scan add simultaneously -ObjC -l"AFNetworking".

Do not give version after AFNetworking in pod file. And try again. Make sure you remove the comma also.

Well, I resolved this, but I'm not sure why it worked. I was experimenting with the Other Linker Flags in the Build Settings. I deleted the flag that was put there by the CocoaPods installation (presumably) and replaced it by copying the flag from the .xcconfig file. Specifically, I added this text: -l"Pods-WeRun-AFNetworking" as the second flag right after -ObjC. It looks to me to be exactly what I had just deleted, so I really hesitate to suggest this as an 'answer', but it works now, so something must have changed.

If anyone can shed any light on this or tell me that I am fooling myself, please let me know. Thanks for the suggestions.

A simple method. Download the repository file. Drag and drop the contents of the AFnetworking folder (You can create groups if necessary) then use the library. (Use #import "AFnetworking.h" )

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!