Does AFNetworking 2.0 support iOS 6.0?

早过忘川 提交于 2019-12-18 03:32:34

问题


AFNetworking 2.0 was announced last week. But I find different requirements for AFNetworking 2.0.

README.md tells it requires either iOS 7.0 and above, while AFNetworking 2.0 Migration Guide tells it requires either iOS 6.0 and above.

Dose AFNetworking 2.0 support iOS 6.0?


回答1:


Accoding to the CocoaPods podspec, you can simply use AFN 2.0 but not include the NSURLSession related files.

For example if you use CocoaPods (if you don't, you should really consider doing it, it's awesome!), simply use this on your Podfile to get AFN 2.0 without NSURLSession-related features:

pod 'AFNetworking', '~> 2.0'

This will only get the "Core" subspec, which supports the deployment target 6.0 for iOS (s.ios.deployment_target = '6.0' in the podspec) and does not integrate NSURLSession-related files. So this will be compatible with your project using an iOS6 or greater deployment target.


If you later wish to drop the 6.0 support on your project and take advantage of the NSURLSession capabilities, you can add the NSURLSession subspec to your Podfile:

pod 'AFNetworking', '~> 2.0' # Core, without NSURLSession, compatible with iOS6
pod 'AFNetworking/NSURLSession', '~> 2.0' # Add NSURLSession features, only compatible with iOS7

You can see in the podspec that adding the NSURLSession subspec will add the s.ios.deployment_target = '7.0' requirement as a consequence, requiring your project's deployment target to be 7.0 or greater too of course, as you could expect.


[EDIT] Since my answer, Mattt updated its code and podspec so that you can get the NSURLSession subspec even when targeting iOS6. See this pull request on its github (and other ones related). So now you can get the NSURLSession subspec even for you iOS6-min projects, and just conditionally call them at runtime only if ([NSURLSession class]) is true.




回答2:


AFNetworking 2.0 is supported in iOS 6. My problem was that I had previously installed it with the platform set to iOS 7. I fixed it by doing this:

  1. Deleted everything from my Podfile
  2. Ran pod install, which deleted all my pods.
  3. Added everything back to my Podfile, with platform :ios, '6.0'

And I was able to still use my existing AFNetworking code with no problems.




回答3:


Yes, it does support iOS6, except for the NSURLSessionTask parts, which are iOS7 only.

I was confused as well, but it looks during the transition from 1.x -> 2.0 not all the docs had yet been updated. They have been now, and it works just fine in my project that supports iOS6.




回答4:


You can use AFNetworking 2.0 .Just have to ensure that the deployment target is set to 6.0 while installing using cocoa pods.I had initially installed AFNetworking when my deployment target was 7.0 .So had to remove it from cocoa pods set deployment target to 6.0 and then do install again.




回答5:


I didn't use pod at all. Instead, I downloaded it and dragged the files to the project, and then encountered this problem as well. To fix it I simply deleted the AFURLSessionManager and AFHTTPSessionManager files from the project. Then it worked.



来源:https://stackoverflow.com/questions/19041584/does-afnetworking-2-0-support-ios-6-0

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