[英]Can we integrate the code of swift in applications having deployment target less than iOS 7?
As Swift supports the mix-match with objective c , then can we use it for building the applications having deployment target less than iOS 7. 由于Swift支持与目标c的混合匹配,因此我们可以使用它来构建部署目标小于iOS 7的应用程序。
from Swift Prerelease Documentation Under the Basic Setup Section what i read is : 来自Swift Prerelease文档在基本设置部分,我读到的是:
Swift is designed to provide seamless compatibility with Cocoa and Objective-C. You can use Objective-C APIs
(ranging from system frameworksto your own custom code) in Swift, and you can use Swift APIsin Objective-C.
This compatibility makes Swift an easy, convenient, and powerful tool to integrate into your Cocoa app
development workflow.
This guide covers three important aspects of this compatibility that you can use to your advantage when
developing Cocoa apps:
● Interoperability lets you interface between Swift and Objective-C code, allowing you to use Swift classes
in Objective-C and to take advantage of familiar Cocoa classes, patterns, and practices when writing Swift
code.
● Mix and match allows you to create mixed-language apps containing both Swift and Objective-C files that
can communicate with each other.
● Migration from existing Objective-C code to Swift is made easy with interoperability and mix and match,
making it possible to replace parts of your Objective-C apps with the latest Swift features.
So after reading this the questions arrises in my mind are 因此,在阅读完之后,我脑海中的问题就出现了
iOS 7 and OS X 10.9 minimum deployment target
iOS 7和OS X 10.9最低部署目标
The Swift compiler and Xcode now enforce a minimum deployment target of iOS 7 or OS X Mavericks.
Swift编译器和Xcode现在强制实施iOS 7或OS X Mavericks的最低部署目标。 Setting an earlier deployment target results in a build failure.
设置较早的部署目标会导致构建失败。
From Xcode 6 release note 来自Xcode 6发行说明
So my previous answer(Shown below) will not be applicable to any further swift development. 所以我之前的回答(如下所示)将不适用于任何进一步的快速发展。 Swift will no longer available for iOS6 and below
iOS版及更低版本将不再提供Swift
Yes you can . 是的,你可以 。 I have tested a simple app written completely in
Swift
in my iOS6 device
, it works perfectly fine. 我已经测试了一个在我的
iOS6 device
完全用Swift
编写的简单应用程序,它运行得很好。 As apple says Swift code is binary compatible to ObjectiveC code. 正如苹果所说,Swift代码与ObjectiveC代码是二进制兼容的。 It uses the same compiler and runtime to create the binary.
它使用相同的编译器和运行时来创建二进制文件。
So if you are not using any new APIs added as part of the iOS8 SDK or some swift specific api's (corresponding api is not available for ObjectiveC) your app will seamlessly work on iOS6+(Tested and working) even iOS5(not tested). 因此,如果您没有使用作为iOS8 SDK的一部分添加的任何新API或一些特定的快速API(相应的API不适用于ObjectiveC),您的应用程序将无缝地在iOS6 +(经过测试和工作)甚至iOS5(未经测试)上工作。 Most of the APIs in the
swift
are just the replacement of the existing ObjectiveC api's. swift
中的大多数API只是现有ObjectiveC api的替代品。 In fact they are same in binary. 实际上它们在二进制中是相同的。
I am not sure but YES swift support lower version of ios in to Xcode Beta if you are check in to Project-->Target-->General-->Deplyment Info
for select deployment target there is drop-down with 6.0,6.1,7.0,7.1 and 8.0 我不知道,但在Xcode的测试版的ios 是迅速支持更低的版本,如果你查的到
Project-->Target-->General-->Deplyment Info
的选择部署目标有下拉与6.0,6.1, 7.0,7.1和8.0
So i think yes swift support lower version. 所以我认为是快速支持较低版本。
I just test the demo that created in Xcode6 with swift language select.
我只是用swift语言选择测试在Xcode6中创建的演示。 then i open this project in to Xcode5 with deployment target 6 and that runs it means that working with lower version too.
然后我打开这个项目到Xcode5,部署目标6,并运行它意味着也使用较低版本。
Here it is a screenshot of swift project runs in xcode5 with ios6.1 simulator: 这是xcode5中使用ios6.1模拟器的swift项目运行的屏幕截图:
HERE IT IS DEMO AS WELL http://www.filedropper.com/demo_5 在这里,它是DEMO以及http://www.filedropper.com/demo_5
Yes you can . 是的你可以 。 I have tested a simple app written completely in Swift in my iOS6 device, it works perfectly fine.
我已经测试了一个在我的iOS6设备中完全用Swift编写的简单应用程序,它运行得很好。 As apple says Swift code is binary compatible to ObjectiveC code.
正如苹果所说,Swift代码与ObjectiveC代码是二进制兼容的。 It uses the same compiler and runtime to create the binary.
它使用相同的编译器和运行时来创建二进制文件。
So if you are not using any new APIs added as part of the iOS8 SDK or some swift specific api's (corresponding api is not available for ObjectiveC) your app will seamlessly work on iOS6+(Tested and working) even iOS5(not tested). 因此,如果您没有使用作为iOS8 SDK的一部分添加的任何新API或一些特定的快速API(相应的API不适用于ObjectiveC),您的应用程序将无缝地在iOS6 +(经过测试和工作)甚至iOS5(未经测试)上工作。 Most of the APIs in the swift are just the replacement of the existing ObjectiveC api's.
swift中的大多数API只是现有ObjectiveC api的替代品。 In fact they are same in binary.
实际上它们在二进制中是相同的。
不,只有iOS 7+和OS X 10.9+。
You can import and run swift code from Objective-C like this: 您可以从Objective-C导入和运行swift代码,如下所示:
#import “ProductModuleName-Swift.h”
MySwiftClass *swiftObject = [[MySwiftClass alloc] init];
[swiftObject swiftMethod];
You can check the iOS version number with this gist and only run the swift code if the version is >= 7.0. 您可以使用此要点检查iOS版本号,如果版本> = 7.0,则只运行swift代码。
是的,使用Swift语言的Xcode 6的最低部署目标是iOS 6.0
Yes you can. 是的你可以。 Its not important in which language you are writing the code.
在编写代码的语言中并不重要。 Finally what matters is compiler and architecture.
最重要的是编译器和架构。 So, you should definitely able to deploy them to OS version less than 7.0
因此,您绝对可以将它们部署到低于7.0的操作系统版本
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.