基于 Swift 的应用程序可以在 OS X 10.9 上运行吗? (Mavericks)/iOS 7 及更低版本?
例如,我有一台机器运行 OS X 10.8 (山狮),我想知道我用 Swift 编写的应用程序是否可以在它上面运行。
或者我应该如何使用 Mac OS 创建 Swift 应用程序?
最佳答案
我刚刚为您测试过,Swift 应用程序编译成标准二进制文件,可以在 OS X 10.9 和 iOS 7 上运行。
用于测试的简单 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
}
关于swift - 基于 Swift 的应用程序可以在 OS X 10.9/iOS 7 及更低版本上运行吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24001778/