Guides and Sample Code


The Swift Programming Language (Swift 4.1)


Version Compatibility

This book describes Swift 4.1, the default version of Swift that’s included in Xcode 9.2. You can use Xcode 9.2 to build targets that are written in either Swift 4 or Swift 3.

When you use Xcode 9.2 to build Swift 3 code, most of the new Swift 4 functionality is available. That said, the following features are available only to Swift 4 code:

  • Substring operations return an instance of the Substring type, instead of String.

  • The @objc attribute is implicitly added in fewer places.

  • Extensions to a type in the same file can access that type’s private members.

A target written in Swift 4 can depend on a target that’s written in Swift 3, and vice versa. This means, if you have a large project that’s divided into multiple frameworks, you can migrate your code from Swift 3 to Swift 4 one framework at a time.