Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does AFNetworking 2.0 support iOS 6.0?

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?

like image 389
Xaree Lee Avatar asked Sep 27 '13 02:09

Xaree Lee


2 Answers

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.

like image 194
AliSoftware Avatar answered Oct 21 '22 07:10

AliSoftware


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.

like image 32
Waynn Lue Avatar answered Oct 21 '22 06:10

Waynn Lue