Swift 3 iOS 兼容性
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/38067678/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Swift 3 iOS compatibility
提问by FelixSFD
I'm new to Apple developing and soon I will distribute my app via AppStore. So now I'm using Swift 3 and by default the deployment target is set to iOS 10.0 It means that I won't be able to make it run for example on iOS 8-9? 'Cos in Swift 3 I use new funcs which are not available in later OS
我是 Apple 开发的新手,很快我将通过 AppStore 分发我的应用程序。所以现在我使用 Swift 3 并且默认情况下部署目标设置为 iOS 10.0 这意味着我将无法让它在例如 iOS 8-9 上运行?' Swift 3 中的 Cos 我使用了在以后的操作系统中不可用的新函数
回答by FelixSFD
You can make your app run on iOS 8 & 9 by setting the Deployment Targetto one of these versions. Swift 3.x is compatible with iOS 8and newer (I'm not sure, but it might be also compatible with iOS 7). The only difference to Swift 2.2 (regarding the system requirements) is that you have to use Xcode 8.
您可以通过将部署目标设置为这些版本之一来使您的应用程序在 iOS 8 和 9 上运行。Swift 3.x 与 iOS 8和更新版本兼容(我不确定,但它可能也与 iOS 7 兼容)。与 Swift 2.2 的唯一区别(关于系统要求)是您必须使用 Xcode 8。
When you set your Deployment Target to an earlier version than iOS 10, you should be aware that you cannot use APIs that are new in iOS 10. (except you use the #available
operator) But using Swift 3 should be no problem.
当您将部署目标设置为比 iOS 10 更早的版本时,您应该意识到您不能使用 iOS 10 中的新 API。(除非您使用#available
运算符)但使用 Swift 3 应该没有问题。
Edit:You can now upload apps written in Swift 3using Xcode 8.0 GM
编辑:您现在可以使用 Xcode 8.0 GM上传以Swift 3编写的应用程序
回答by Ahmad F
You should use Swift 3.x (it's the latest version of Swift since this answer has been posted).
您应该使用 Swift 3.x(它是 Swift 的最新版本,因为这个答案已经发布)。
iOS version is NOT related to the Swift version you should use, instead, some of the new provided apis do support a minimum version of the OS. But -again- it's not related to the programming language it self. For example: an application has been built via Swift 2.x (Deployment Target 9.x) should work on iOS 10; When updating the IDE (xcode), it will support -by default- the latest version of the programming language -Swift-.
iOS 版本与您应该使用的 Swift 版本无关,相反,一些新提供的 api 确实支持操作系统的最低版本。但是 - 再次 - 它与它本身的编程语言无关。例如:通过 Swift 2.x(部署目标 9.x)构建的应用程序应该可以在 iOS 10 上运行;更新 IDE (xcode) 时,它将默认支持最新版本的编程语言 -Swift-。
Also,You could do:
另外,你可以这样做:
if #available(iOS 10, *) {
// use an api that requires the minimum version to be 10
} else {
// use another api
}