Domanda

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?

È stato utile?

Soluzione

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.

Altri suggerimenti

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.

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.

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.

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top