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

例如,我想知道我是否会在Mountain上运行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相关问答推荐

创建一个DeliverMacro,该DeliverMacro创建带有注入一致性的嵌入式 struct

Variadic泛型与Swift中的值和类型参数包

如何在AudioKit中实现自定义音效 node ?

应该在ViewModel还是ViewController中使用"Task {}"?

从 Obj-C 函数返回 swift 类的不兼容指针类型

RealityKit - 从中心zoom 模型

快速递归:函数与闭包

您是否必须手动指定您的 DispatchQueue 是串行的?

带有屏幕参数的 NSWindow 初始化程序在初始化时导致致命错误

引用类型(类)不需要但 struct 需要的可识别 id

将阻塞函数集成到 Swift 异步中

在 SwiftUI 中,如何在 UIView 内或作为 UIView 使用 UIHostingController?

如何在 iOS Swift 中进行多线程、并发或并行?

Swift 3:小数到 Int

哪些版本的 Xcode 支持哪些版本的 Swift?

Swift if 语句 - 多个条件用逗号分隔?

如何发送静默推送通知有效负载

使用 Swift 以编程方式自定义 UITableViewCell

在 Swift 中覆盖 UIScrollView 的委托属性(就像 UICollectionView 一样)

如何快速显示数组的所有元素?