Today, Apple released Swift 2.2 for OSX and Linux, which is the first release since the project was open-sourced last year. It contains a number of contributions from non-Apple employees as well as a number of source-incompatible changes.
To celebrate the release, until the end of March, my Swift Essentials book has a 50% off discount for the eBook and a 30% off discount for the printed book. More information is available on the Swift Essentials website.
The changes for Swift 2.2 include:
- The removal of the C-style
for
loop (SE-0007) - The removal of increment
++
and decrement--
operators (SE-0004) - The replacement of
typealias
withassociatedtype
as a keyword (SE-0011) - Using
#selector(foo)
instead ofSelector("foo")
(which is now compile checked) to fit in better with # designated operators in Swift (SE-0022) - The addition of #if as a build-time and operating-system time test (SE-0020)
Any code that has:
1 2 3 |
|
needs to be refactored to:
1 2 3 |
|
Any references to:
1
|
|
needs to be refactored to:
1
|
|
Using the Swift version syntax allows for different paths to be taken by the compiler in the code:
1 2 3 4 5 6 7 8 9 10 11 |
|
and can be used to selectively enable new features based on the release:
1 2 3 4 5 6 7 |
|
Fix-its built into Xcode 7.3 (which was released at the same time) will allow you to migrate code from one version to another.
Xcode 7.3 is avaliable from Apple for OSX, and Swift 2.2 is available from the Swift website for OSX and Ubuntu.