简体   繁体   English

我们可以将swift代码集成到部署目标低于iOS 7的应用程序中吗?

[英]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 因此,在阅读完之后,我脑海中的问题就出现了

  1. Can we use swift for the applications we are currently working on. 我们可以将swift用于我们目前正在开发的应用程序。
  2. If the answer is no then it will be contradict to the above explanation. 如果答案是否定则则与上述说明相矛盾。

Update - As per Xcode 6 Beta 4 更新 - 根据Xcode 6 Beta 4

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.

相关问题 我们可以将AFNetworking集成到企业级iOS应用程序中吗 - Can we Integrate AFNetworking in Enterprise level iOS Applications Swift:iOS部署目标命令行标志 - Swift: iOS Deployment Target Command Line Flag swift 5 的最低 ios 部署目标是什么? - What is the minimum ios deployment target for swift 5? 为多个架构构建的应用程序需要 3.0 或更高版本的 iOS 部署目标。 STATE_ERROR.VALIDATION_ERROR.90081 - Applications built for more than one architecture require an iOS Deployment Target of 3.0 or later. STATE_ERROR.VALIDATION_ERROR.90081 我们可以将IOS应用程序与OneLogin集成吗? - Can we integrate IOS application with OneLogin? iOS - 带有部署目标 &lt; 14 的应用的 Ship Widget 扩展 - iOS - Ship Widget Extension with app having deployment target < 14 我们是否需要将 iOS 部署目标设置为 13.0? - do we need to set iOS deployment target to 13.0? iOS-将框架链接到比我项目的部署目标更高的部署目标 - iOS - Link a framework with higher deployment target than my project's iOS通用应用程序:最低操作系统版本与部署目标不同 - iOS Universal Application: the Minimum OS Version is Different than the Deployment Target 为什么我们仍然在swift ios应用程序中使用NSDictionary和NSArrays? - Why do we still use NSDictionary and NSArrays in swift ios applications?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM