基于 Swift 的应用程序是否可以在 OS X 10.9/iOS 7 及更低版本上运行? [英] Do Swift-based applications work on OS X 10.9/iOS 7 and lower?

查看:24
本文介绍了基于 Swift 的应用程序是否可以在 OS X 10.9/iOS 7 及更低版本上运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基于 Swift 的应用程序能否在 OS X 10.9 (Mavericks)/iOS 7 及更低版本上运行?

Will Swift-based applications work on OS X 10.9 (Mavericks)/iOS 7 and lower?

例如,我有一台运行 OS X 10.8 (Mountain Lion) 的机器,并且我我想知道我用 Swift 编写的应用程序是否可以在其上运行.

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.

或者我应该如何使用 Mac OS 创建 Swift 应用程序?

Or what should I have to create a Swift application using Mac OS?

推荐答案

我刚刚为您测试了它,Swift 应用程序编译为标准二进制文件,可以在 OS X 10.9 和 iOS 7 上运行.

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 应用程序:

Simple Swift application used for testing:

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 的应用程序是否可以在 OS X 10.9/iOS 7 及更低版本上运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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