What is min supported iOS for Swift 5.1? - ios

What is the min iOS which works well with Swift 5.1 or incoming Swift 5.2?
Are there any references to check this?

A similar question has been asked before, when Swift 4 came out. You can find the question and answer here.
Having that said, the swift.org site and the release notes only specify the compatibility with previous Swift versions, the operating systems and the toolchain (Xcode). So, a straight forward answer can't be given to this question.
Since Swift 5.1 is compatible with Swift 4, you can safely assume the code will run iOS 11 and probably iOS 10 as well. There are, however, some incompatibilities between Swift 5.1 and Swift 4, see for the details this link. I think you should also be aware of the fact that as of iOS 11 32 bit is not being supported anymore.
The next issue you will definitely run into are the deprecated functions in iOS. You have to build your code in the productive version of Xcode and that tool will throw errors and warnings for deprecated functions or variables being changed. For instance, the key "[UIImagePickerControllerOriginalImage" has been changed to "UIImagePickerController.InfoKey.originalImage". at the moment Xcode 11.3 doesn't let you specify below 12.1, so you will run into these problems when updating source code written in an older version.

Related

Swift framework for all Xcode versions

I provide a Swift framework for my customers.
It would only work in Xcode 10.3 (Or am I doing anything wrong?)
For other Xcode, it does have Swift compatibility issues.
So I am planning to release a series of versions of my framework so that a customer with a particular Xcode version can have the respective framework version of mine.
And it is pretty complex. Because for every release or bug fix I need to generate a bunch of versions.
I just want validation if this is the right approach.
How do I simplify this?
The compatibility issue you have is not from the version of the Xcode, is from the Swift version of the Framework. There is a difference.
In every project you can set the Swift version, but unfortunately you can't have more than one swift version per project. The current accepted ones are Swift 4, Swift 4.2 or Swift 5, as you can see in Xcode > Target > Build Settings:
Xcode 10.0 was the last version to support Swift 3 and is currently obsolete. I wouldn't create a framework version for it.
So, I would recommend you to either focus only on the latest Swift version and create a new Framework version every time a new Swift version appears (the most common approach), or start with the current three Swift versions and give them maintenance until the Swift version is deprecated.

Unsupported Swift Version 3.x in Xcode 10.3

I keep downloading sample codes and many times it says "Unsupported Swift Version 3.x...Use Xcode 10.1 to migrate the code to Swift 4".
Why is it not possible to migrate to Swift 4 using Xcode 10.3 or Xcode 11 beta?
More importantly, I am using Swift 4.2 in my own Project that has several dependancies as well through Pods. If I don't upgrade to Swift 5.1 or later, it seems my own project would start getting such errors in Xcode 12 or so, correct? While I can convert my own code to Swift 5.1, I have no idea if dependencies such as SwiftyDropbox would migrate to Swift 5.1 so easily. What implications it would have for my project in future and what could I do to future proof my project in that case?
Ask Apple. The company has decided – certainly for good reasons – to migrate files only to the Current Swift Syntax. Feel free to create legacy system partitions with older versions of Xcode to migrate code step by step.
The grace period to update the Swift version is long enough to ensure a smooth transition. At least Xcode allows to use the 3 most recent Swift versions in the same project. However you are responsible to maintain the version control. Check the dependencies periodically for updates. If a dependency is not able to release an update within the grace period it's not much good.

Why Projects made in Swift 3 or lower gives error new Xcode 9 supporting swift 4.1?

Its been a very tough for me to get a suitable answer for this Question as I know the solution but the reason is still unknown
Let me explain the question properly, when we make any projects like in swift 3 or lower version in lower versions of Xcode like 7 or 8
Its Doest run in new Xcode version like 9 we have to change the Swift_version in build settings to make it work.
Why doest it happen why Xcode doesn't support all versions of swift like I can show us deprecated warning rather then throwing error
for Obj c It works in all Xcode whatever Xcode you use it supports Obj c
Because Xcode 9 does not ship with older Swift versions. You need to update your Swift code.
Generally, Xcode also does not support older Obj-C versions, but Obj-C syntax hardly changes from year to year, that is why Obj-C code that you wrote in Xcode 7 runs in Xcode 9. But this was not the case for Obj-C code you wrote in say Xcode 2 or lower.

Swift 3.0 will not be 2.2 source compatible... will I have to rebuild my apps?

http://thenextweb.com/apple/2016/05/09/swift-3-0-developer-previews-wwdc/#gref
Does this mean anything? Will I have to completely rebuild my apps or merely convert 2.2 syntax to 3.0?
Swift 3.0 will not be compatible with 2.2. Here is the list of the current proposals, it also details what has been implemented already, and what will be :
https://github.com/apple/swift-evolution
You will not have to entirely rebuild your App, but you will have to adapt your code.
I'd say no. Every Swift app comes with its own runtime and standard libraries of whatever Xcode version you used to build it. Some of my Swift 1.0 app still runs on the latest version of El Capitan.
Source incompatibility means you can't take valid code written in Swift 2, feed it to the Swift 3 compiler and expect everything to go smoothly. There will be errors and deprecation warnings, much of which you already see today with Swift 2.3.
You also can't take a compiled application written in Swift 2 and make it run without modification on a Swift 3 runtime either. Swift is lacking a stable Application Binary Interface (ABI) at the moment. That's why every Swift app must carry its own runtime. OS X and iOS don't provide those at the system level. Hence Swift app tends be larger in size, more of a problem on iOS than OS X.
With Swift 3, Apple is trying to establish a stable ABI so your compiled Swift 3 can run without modification on the Swift 4 runtime, whenever that comes.
What about source code compatibility? No one knows what Chris Lattner has in mind or what he considers archaic. Removing the ++ and -- operator in Swift 3 seem superfluous to me. And why kill C-style for loop too?
I'm currently adapting all my code to the present state of Swift 3. The existing code is certainly not compatible; most methods have been renamed, case names have been lowercased, and so on. To what extent Apple will assist by providing a migration tool is unknown, as that's in the future.
#CodeDifferent provided a great answer, but I'd like to extend on it.
AFAIK, if your Swift 2 app is compiled with its own runtime linked in (i.e., not relying on the system runtime), then your app will run fine & there's no need to rebuild on a Swift 3 machine to run on a Swift 3 machine. But if there's no runtime compiled into the app, then your app won't run on a machine with a Swift 3 ABI.
Of course, if you are going to compile with application with Swift 3, then you will have to re-build.

Swift 2.0 / iOS 9 Compatibilities

I have a few issues concerning the recent addition of Swift 2.0 and upcoming iOS9.
Currently I have been working on an app that works with iOS7 or above, and using Swift 1.2 things...nothing that Swift 2 has. I was told that I should start updating everything to include Swift 2 rather than the older ways of using Swift. So my questions are...
1) If I do begin to work with Swift 2 code, will iOS 7 and iOS 8 be able to recognize that code, or does Swift 2 only work with certain versions of iOS?
2) If I choose NOT to work with the Swift 2 code and stick with what I have that works already for iOS 7 and 8, is it possible that in iOS9 or later, it won't work because it expects Swift 2 and it's not getting it?
I have looked for compatibility articles and answers online and found nothing. The only thing I've learned is that Swift 2 just adds code, and doesn't necessarily change anything...so maybe just keeping my old code would be okay. But again I'm not exactly sure. Thanks.
The code will work as far back as iOS 7 for right now, regardless of what version of Swift you are using. As far as whether you should update your code, that's up to you, but of course Swift 2.0 does offer a lot more in terms of safety and error checking so if you find situations where it would be pertinent to implement such new features, then you probably should. Also some syntax is different, but if you update now you'll just be future-proofing yourself.

Resources