Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

from Swift Prerelease Documentation Under the Basic Setup Section what i read is :

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.
  2. If the answer is no then it will be contradict to the above explanation.
like image 849
iShwar Avatar asked Jun 04 '14 12:06

iShwar


People also ask

What is minimum deployment target iOS?

That is the iOS deployment target or the minimum deployment target for iOS. It means that the application runs on any iOS device with iOS 14.3 or later installed. The values the dropdown menu lists depend on the version of Xcode you are using. Xcode 12, for example, no longer supports iOS 8.

How do I change the minimum deployment target in Xcode?

To change your deployment target, open up your project file in Xcode and check the setting under Build Settings -> Deployment(...) Check this answer to add earlier devices support.

What is iOS deployment target in Xcode?

In short, every application that runs on one of Apple's platforms has a deployment target. A deployment target is nothing more than the minimum version of the operating system the application can run on. Fire up Xcode and create a new project by choosing the App template from the iOS > Application section.


2 Answers

Update - As per Xcode 6 Beta 4

iOS 7 and OS X 10.9 minimum deployment target

The Swift compiler and Xcode now enforce a minimum deployment target of iOS 7 or OS X Mavericks. Setting an earlier deployment target results in a build failure.

From Xcode 6 release note

So my previous answer(Shown below) will not be applicable to any further swift development. Swift will no longer available for iOS6 and below


Yes you can . I have tested a simple app written completely in Swift in my iOS6 device, it works perfectly fine. As apple says Swift code is binary compatible to ObjectiveC code. 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). Most of the APIs in the swift are just the replacement of the existing ObjectiveC api's. In fact they are same in binary.


like image 155
Anil Varghese Avatar answered Oct 28 '22 11:10

Anil Varghese


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

enter image description here

enter image description here

So i think yes swift support lower version.

I just test the demo that created in Xcode6 with swift language select. then i open this project in to Xcode5 with deployment target 6 and that runs it means that working with lower version too.

Here it is a screenshot of swift project runs in xcode5 with ios6.1 simulator:

enter image description here

HERE IT IS DEMO AS WELL http://www.filedropper.com/demo_5

like image 36
Nitin Gohel Avatar answered Oct 28 '22 13:10

Nitin Gohel