AFNetworking 2.0是否支持iOS 6.0? [英] Does AFNetworking 2.0 support iOS 6.0?

查看:105
本文介绍了AFNetworking 2.0是否支持iOS 6.0?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

AFNetworking 2.0上周宣布。但我发现AFNetworking 2.0有不同的要求。

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

README.md 告诉它需要iOS 7.0及更高版本,而 AFNetworking 2.0迁移指南告诉它需要iOS 6.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.

剂量AFNetworking 2.0支持iOS 6.0?

Dose AFNetworking 2.0 support iOS 6.0?

推荐答案

根据 CocoaPods podspec ,你可以简单地使用AFN 2.0但不包括 NSURLSession 相关文件。

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

例如,如果您使用CocoaPods(如果您不这样做,那么您应该考虑这样做,它真棒!),只需在您的Podfile上使用它就可以获得AFN 2.0而无需 NSURLSession 相关功能:

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'

这只会得到Core subspec,支持iOS的部署目标6.0(podspec中的 s.ios.deployment_target ='6.0')并且不集成 NSURLSession 相关文件。因此,这将与使用iOS6或更高部署目标的项目兼容。

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.

如果您以后希望删除6.0支持您的项目并利用 NSURLSession 功能,您可以将 NSURLSession subspec添加到 Podfile

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

您可以在 podspec 添加 NSURLSession subspec将添加 s.ios.deployment_target ='7.0'要求因此,要求你的项目的部署目标当然也是7.0或更高,正如你所料。

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.

自从我的回答以来,Mattt更新了它的代码和podspec,这样即使面向iOS6,你也可以获得 NSURLSession subspec。请参阅此github上的拉取请求(以及其他相关请求)。
所以现在你可以获得 NSURLSession subspec,即使是iOS6-min项目,也只是在运行时有条件地调用它们 if([ NSURLSession类])为真。

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.

这篇关于AFNetworking 2.0是否支持iOS 6.0?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆