I'm new to Apple developing and soon I will distribute my app via AppStore. So now I'm using Swift 3 and by default the deployment target is set to iOS 10.0 It means that I won't be able to make it run for example on iOS 8-9? 'Cos in Swift 3 I use new funcs which are not available in later OS
You can make your app run on iOS 8 & 9 by setting the Deployment Target to one of these versions. Swift 3.x is compatible with iOS 8 and newer (I'm not sure, but it might be also compatible with iOS 7). The only difference to Swift 2.2 (regarding the system requirements) is that you have to use Xcode 8.
When you set your Deployment Target to an earlier version than iOS 10, you should be aware that you cannot use APIs that are new in iOS 10. (except you use the #available operator) But using Swift 3 should be no problem.
Edit: You can now upload apps written in Swift 3 using Xcode 8.0 GM
You should use Swift 3.x (it's the latest version of Swift since this answer has been posted).
iOS version is NOT related to the Swift version you should use, instead, some of the new provided apis do support a minimum version of the OS. But -again- it's not related to the programming language it self. For example: an application has been built via Swift 2.x (Deployment Target 9.x) should work on iOS 10; When updating the IDE (xcode), it will support -by default- the latest version of the programming language -Swift-.
Also, You could do:
if #available(iOS 10, *) {
// use an api that requires the minimum version to be 10
} else {
// use another api
}
Related
I'm new to iOS development, trying to develop an application.
Once I've seen in these statistics that iOS 7 has a really small market share I decided to support iOS 7 or higher in a way to make an app to all iphone OS available in the market. I also decided to use swift as code language but not sure which swift version should I choose.
Which swift version should I choose for iOS 7 or higher development?
Apple states that
Starting July 2018, all iOS app updates submitted to the App Store must be built with the iOS 11 SDK and must support the Super Retina
display of iPhone X.
(The same requirement for new apps started on April 2018.)
So, your choice are very few, Xcode 9 (with iOS 11 SDK) or Xcode 10 (with iOS 12 SDK).
(I believe we should read the requirement as iOS11 SDK or later.)
And supporting iOS 7 with Xcode 9/10 is very difficult. (I do not know if it is possible or not.) Deployment Target does not accept versions less than 8.0 (*), and iOS 7 Simulators are not provided.
(*) Some versions of Xcode replaces versions less than 7.0 to 8.0, even if I entered the version number manually. And at least, both Xcode versions does not show 7.x in the popup menu of the Deployment Target.
I recommend you to use the latest released version of Xcode (10, which comes with Swift 4.2), and make your minimum supported version to iOS 8.0 or later.
The Swift application will work only on iOS 7+. The Xcode will add the Swift library to every build so, you can use any version of Swift language and all of them will work on all iOS starting from 7th. Apps created with Swift will run on iOS 7+ and Mac OS 10.9 +
so use the latest version always.
You have to use the latest swift version Swift 4.2
As iOS 12 is out now so you have to use iOS 10 and above because we should support recent 3 versions.
Images source
If you target iOS 10 and above then you hit the 95% users
I have project with iOS Deployment Target 8.0 but I want update to iOS to support devices iOS 10 - 11.3
How to do it right
im need to change Deployment Target and it will work?
I can't find an answer to this problem
How can i do this? Thanks
If you wish to support iOS 11.3 you need to upgrade to Xcode 9.3.
That will include Swift 4.1 so you may get a lot of new warnings and errors in your Swift code depending on what version you are currently using.
Your project's Deployment Target has nothing to do with any of this. The Deployment Target defines the oldest version of iOS your app supports. If you keep your Deployment Target at iOS 8.0 (or anything earlier than the latest version of iOS) then you need to make sure that your code properly ensures that newer APIs are not used on older devices.
I have recently updated to Xcode 8. Previously I was using Xcode 7 with Swift 2.2.
I have a framework that I built in with deployment target iOS 9.3. Now that I have moved to Xcode 8 I cannot use this framework.
Is there a way I can build a framework that will work for iOS sdks 8 and above?
I want to set the minimum deployment target of my app to iOS 8+.
Also
Alamofire for Swift 3 has been updated and I have updated my pod file.
Will I be able to run the app in iOS versions above 8?
Any help will be appreciated.
Yes it is possible to build frameworks for iOS 8 with Xcode 8. But if you try to support iOS 8 you could also use Swift 3, put If you use other frameworks like Alamofire, you have to be careful, because the latest version of Alamofire (4.x) requires a minimum iOS target version of iOS 9. So you have to use Alamofire (3.x). With Alamofire 3.5 you have to use Swift 2.3
So first you have to decide what's more important for you:
iOS 8 support: So you have to switch to Swift 2.3 and Alamofire 3.x
Swift 3 support: So you have to drop iOS 8 support, because Alamofire 4.x requires iOS 9
As you know that Xcode 8 supports only Swift 2.2 and Swift 3. Your framework is built on top of Swift 2.2. So there is no way that you can run or build the project in Xcode 8, you will get an error like "The project has an older version of Swift, Please build it with newer version of Xcode".
You can use Xcode 8 and you can set minimum deployment target to iOS 8. But you can't use any of the new Swift 3 features in there, I mean you can use it but it will not execute in iOS 8. For that you have to write code with class or API availability checking for each snippet you write.
If you use new version of Alamofire there is no chance that you can use it in iOS 8.0. You need an older version of it. Because Alamofire new version is Swift 3 and have minimum deployment target of iOS 10 I think.
So it is better to convert your project into Swift 3 or to Swift 2.3. That is the best way to solve this situation. Otherwise you will see more lot of problems eventually.
For example, in swift 3 there is a new type and property: Calendar.current, does it support for iOS 8?
The document said the SDK is iOS 10+, but I can run a app using this type property on iOS 8 device. This is very strange.
I want to know is there any place to check the minimum iOS version support for a type, property and function?
Or may be just the document is not updated? I use Xcode 8 GM version.
The Swift Syntax that is available is dependant on the development environment (The version of Xcode), not the iOS platform that Xcode is building for. Therefore swift 3.0 syntax will be valid for any project for any iOS version that is built using Xcode 8+ (assuming you have not enabled the setting to use legacy swift, which uses the older syntax)
As #Eric Aya said, just because it's new for Swift 3 doesn't mean that it won't work on earlier versions of iOS.
This is (somewhat) equivalent to the change of CGRectMake() to CGRect(). You can't use CGRectMake() in Swift 3, but its replacement will work for pre iOS 10 (how else would you do it?).
Swift 3 will work for any project being made in Xcode 8 (unless you specifically choose Swift 2). It does not take into account which version of iOS or which device.
You can read more at the official Swift 3 migration guide.
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
Can we use swift for the applications we are currently working
on.
If the answer is no then it will be contradict to the above
explanation.
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.
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
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:
HERE IT IS DEMO AS WELL 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. 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.
No, only iOS 7+ and OS X 10.9+.
You can import and run swift code from Objective-C like this:
#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.
Yes, the minimum deployment target for Xcode 6 with Swift language is 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