Apple Releases Swift 2.2 for OSX and Linux
Apple has released Swift 2.2, the latest version of their mobile and server programming language. This version is the first official release that has been contributed to by open-source developers, including contributions from 212 non-Apple contributors. Some of these are typos, contributed in the first few days of Apple's open-source Swift release, leading Chris Lattner to proclaim:
Swift's comments and test suite are on track to be one of the most correctly spelled and best indented ones in the industry!— Chris Lattner (@clattner_llvm) 5 December 2015
The release also includes a number of enhancements that have followed Swift's evolution process, including some proposed by non-Apple contributors:
- SE-0001: Allow (most) keywords as argument labels
- SE-0015: Tuple comparison operators
- SE-0014: Constraining
- SE-0011: Replace
associatedtypefor associated type declarations
- SE-0021: Naming Functions with Argument Labels
- SE-0022: Referencing the Objective-C selector of a method
- SE-0020: Swift Language Version Build Configuration
The Swift project has expanded to allow others to commit directly to the repository, for those that have published good work in the past.
Swift 2.2 is included with Apple's release of Xcode 7.3, which has also been published. The official release means that iOS applications can now be submitted to the AppStore using Swift 2.2. For Linux builds, official binaries are available for Ubuntu 14.04 and 15.10. However, the Linux port is not yet complete; there are a number of missing components in the standard swift core libraries that are scheduled to appear in Swift 3 later this year. The IBM Swift sandbox is currently running a development build of Swift 3.0 but may add a Swift 2.2 option as well in the near future.
The ongoing development of the Swift Package Manager means that it is not yet part of the official builds; it too is scheduled to be released with Swift 3.0.
Changes in Swift 2.2
There are a number of changes in Swift 2.2 which will affect existing source code written for previous versions. These include:
- Removal of the C-style
forloops, along with the increment ++ and decrement -- operators.
- Functions can no longer be defined as taking curried arguments directly, but instead return a function that takes an operator.
- Objective-C selectors can be referenced using
Selector("doSomething"), and is now compile-time checked.
- Most keywords can now be used as argument labels
- Associated types can now be related to a protocol, allowing them to have generics in classes that adopt the protocols.
The language book also includes a description of Automatic Reference Counting which may have not been clear before.
Swift 2.2 is available for immediate download via the Swift website.