The ever changing nature of Swift and how to keep up with it

If you learned a language, that was it, you did not have to re-learn the same. There could have been additions or extensions to the language but it would not have changed. Welcome to the future, nothing is constant and nothing is static. Though Swift is a production release, ie. you can use it in development and create apps using the same, it is changing and evolving.
The first Major change was when Swift 1.0 was released, those Authors that had started their books as soon as Swift was released must have had a tough time updating their code and references. Then there was the second lot of authors that used Swift 1.0 but the books were ready before Swift 1.2 and then there are those that are post Swift 1.2 or update editions.

First, Books are not a website that can be updated and everything changes automatically. So if you are following a book for your swift learning needs, the text is correct and applicable for the version of Swift that it was written with. It would be strange if you tried to look up your own school records for years before you were born and get frustrate that they did not exist. Similarly, it would be strange and weird that a book completed and printed prior to the release of Swift 1.2 would have code updated for the same. I have seen a lot of comments from readers that specifically highlight this concern. Mainly. these are the beginner developers that want to simply copy/paste the code into their projects and expect that to work. When the code does not work, they start crying afoul. Another analogy from the Automobile industry, if you were to buy a new car, you get a new car, but for those that know there is a cut off around September (depending on the manufacturer) so any car that was build prior to September is the previous year model and the ones after that are this year model. The cars could be made in say Aug/Sept and Oct, all three are new cards but one is previous year model.

How to fix this issue

When you open your project in Xcode and try to compile, Xcode will throw errors at you. Which to a beginner that has no previous experience with Xcode, Swift or Apple Development would be very disorienting. However the one good thing is that Xcode makes suggestions and in most cases than not, the fixes are as simple as replacing as with as! and that would be offered as a fix-it suggestion.

In some advanced scenarios you might have issues where this would not work. Apple understands this and has an in-built option to convert your Swift project to the latest version. In most cases it will fix only about 50% of the problems, and they would generally be just replacing the as .

I am sure that everyone, be it authors of books or writers of tutorials, everyone is reeling from this rapid changes to syntax that breaks the earlier code. Generally most code or technology used to be backwards compatible, however in the past 10-12 years the industry has adopted a scrap and move on policy, be it the gaming consoles, I know someone that had a huge collection of PS2 games but had to chuck them out as they would not work with PS3. Same goes for the PS3 -> PS4 or the XBox -> XBox360 -> XBOne.

I want to close with what I find funny about this, it is beautifully summarized in an Oatmeal comic here

Views All Time
Views All Time
Views Today
Views Today
Posted in Tip and tagged , , , .