本文翻译自:Do Swift-based applications work on OS X 10.9/iOS 7 and lower?
Will Swift-based applications work on OS X 10.9 (Mavericks)/iOS 7 and lower? 基于Swift的应用程序能否在OS X 10.9 (Mavericks)/ iOS 7及更低版本上运行?
For example, I have a machine running OS X 10.8 (Mountain Lion), and I am wondering if an application I write in Swift will run on it. 例如,我有一台运行OS X 10.8 (Mountain Lion)的计算机,我想知道我用Swift编写的应用程序是否可以在其上运行。
#1楼
参考:https://stackoom.com/question/1chxS/基于Swift的应用程序是否可以在OS-X-iOS-及更低版本上运行
#2楼
Swift uses the same runtime as Objective-C and can even live side-by-side Objective-C in the same application (as per the WWDC 2014 keynote). Swift使用与Objective-C相同的运行时,甚至可以在同一应用程序中并排使用Objective-C(根据WWDC 2014主题演讲)。
This will need to be checked/verified using Xcode 6 and the new SDK to find a final answer. 这需要使用Xcode 6和新的SDK进行检查/验证,以找到最终答案。
#3楼
I just tested it for you, Swift applications compile into standard binaries and can be run on OS X 10.9 and iOS 7. 我刚刚为您测试过,Swift应用程序可以编译为标准二进制文件,并且可以在OS X 10.9和iOS 7上运行。
Simple Swift application used for testing: 用于测试的简单Swift应用程序:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool {
self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
var controller = UIViewController()
var view = UIView(frame: CGRectMake(0, 0, 320, 568))
view.backgroundColor = UIColor.redColor()
controller.view = view
var label = UILabel(frame: CGRectMake(0, 0, 200, 21))
label.center = CGPointMake(160, 284)
label.textAlignment = NSTextAlignment.Center
label.text = "I'am a test label"
controller.view.addSubview(label)
self.window!.rootViewController = controller
self.window!.makeKeyAndVisible()
return true
}
#4楼
Apple has announced that Swift apps will be backward compatible with iOS 7 and OS X Mavericks. 苹果已经宣布,Swift应用程序将与iOS 7和OS X Mavericks向后兼容。 The WWDC app is written in Swift. WWDC应用程序是用Swift编写的。
#5楼
Swift code can be deployed to OS X 10.9 and iOS 7.0. 可以将Swift代码部署到OS X 10.9和iOS 7.0。 It will usually crash at launch on older OS versions. 在较旧的OS版本上启动时,它通常会崩溃。
#6楼
尽管代码确认了这一点,但苹果公司本身已经在2014年WWDC的技术主题演讲( 平台状态,第 102场,大约34分00秒)中表示,Swift将与iOS 7和Mavericks兼容。