Swift Changelog

What's new in Swift 4.2

September 18th, 2018
  • Swift 4.2 builds on the strengths of Swift 4, delivering faster compile times, improving the debugging experience, updating the standard library, and converging on binary compatibility.
  • Further details on this release are available at:
  • http://swift.org/blog/swift-4-2-released/

New in Swift 4.1 (March 30th, 2018)

  • Updates to the core language, including more support for generics, new build options, as well as minor enhancements to Swift Package Manager and Foundation. There was also significant progress made in stabilizing the ABI.
  • Further details on this release are available at:
  • http://swift.org/blog/swift-4-1-released/

New in Swift 4.1 Build 2017-11-01-a Dev (November 2nd, 2017)

  • SE-0157 is implemented. Associated types can now declare "recursive" constraints, which require that the associated type conform to the enclosing protocol. The standard library protocols have been updated to make use of recursive constraints.
  • SE-0161 is fully implemented. KeyPaths now support subscript, optional chaining, and optional force-unwrapping components.
  • SE-0186: It is no longer valid to use the ownership keywords weak and unowned for property declarations in protocols. These keywords are meaningless and misleading when used in a protocol as they don't have any effect. In Swift 3 and 4 mode the following example will produce a warning with a fix-it to remove the keyword. In Swift 5 mode and above an error will be produced.
  • SE-0185: Structs and enums that declare a conformance to Equatable/Hashable now get an automatically synthesized implementation of ==/hashValue. For structs, all stored properties must be Equatable/Hashable. For enums, all enum cases with associated values must be Equatable/Hashable. If you wish to provide your own implementation of ==/hashValue, you still can; a custom implementation will replace the one synthesized by the compiler.

New in Swift 3.1 (March 28th, 2017)

  • SE-0080: Adds a new family of conversion initializers to all numeric types that either complete successfully without loss of information or return nil.
  • Swift will now warn when an NSObject subclass attempts to override the class initialize method. Swift doesn't guarantee that references to class names trigger Objective-C class realization if they have no other side effects, leading to bugs when Swift code attempted to override initialize.
  • SR-2394: C functions that "return twice" are no longer imported into Swift. Instead, they are explicitly made unavailable, so attempting to reference them will result in a compilation error.
  • Indirect fields from C structures and unions are now always imported, while they previously weren't imported if they belonged to a union. This is done by naming anonymous fields.
  • The withoutActuallyEscaping function from SE-0103 has been implemented. To pass off a non-escaping closure to an API that formally takes an @escaping closure, but which is used in a way that will not in fact escape it in practice, use withoutActuallyEscaping to get an escapable copy of the closure and delimit its expected lifetime.
  • SR-1446: Nested types may now appear inside generic types, and nested types may have their own generic parameters.
  • SR-1009: Constrained extensions allow same-type constraints between generic parameters and concrete types.
  • SE-0045: The Sequence protocol adds two new members prefix(while:) and drop(while:) for common utility. prefix(while:) requests the longest subsequence satisfying a predicate. drop(while:) requests the remaining subsequence after dropping the longest subsequence satisfying a predicate.

New in Swift 3.1 Build 2017-01-22-a Dev (January 24th, 2017)

  • Adds a new family of conversion initializers to all numeric types that either complete successfully without loss of information or return nil.
  • Swift will now warn when an NSObject subclass attempts to override the class initialize method. Swift doesn't guarantee that references to class names trigger Objective-C class realization if they have no other side effects, leading to bugs when Swift code attempted to override initialize.
  • C functions that "return twice" are no longer imported into Swift. Instead, they are explicitly made unavailable, so attempting to reference them will result in a compilation error.
  • Indirect fields from C structures and unions are now always imported, while they previously weren't imported if they belonged to a union. This is done by naming anonymous fields.
  • The withoutActuallyEscaping function from SE-0103 has been implemented. To pass off a non-escaping closure to an API that formally takes an @escaping closure, but which is used in a way that will not in fact escape it in practice, use withoutActuallyEscaping to get an escapable copy of the closure and delimit its expected lifetime.
  • Nested types may now appear inside generic types, and nested types may have their own generic parameters.
  • Constrained extensions allow same-type constraints between generic parameters and concrete types.
  • The Sequence protocol adds two new members prefix(while:) and drop(while:) for common utility. prefix(while:) requests the longest subsequence satisfying a predicate. drop(while:) requests the remaining subsequence after dropping the longest subsequence satisfying a predicate.

New in Swift 3.0 2016-05-31-a Preview 1 (May 31st, 2016)

  • SE-0081 "Move 'where' clause to end of declaration" is implemented, allowing you to write 'where' clauses after the signature for a declaration, but before its body.
  • SE-0071: "Allow (most) keywords in member references" is implemented. This allows the use of members after a dot without backticks, e.g. "foo.default".
  • SE-0057: Objective-C lightweight generic classes are now imported as generic types in Swift.
  • SE-0055: The types UnsafePointer, UnsafeMutablePointer, AutoreleasingUnsafeMutablePointer, OpaquePointer, Selector, and Zone (formerly NSZone) now represent non-nullable pointers, i.e. pointers that are never nil. A nullable pointer is now represented using Optional, e.g. UnsafePointer? For types imported from C, non-object pointers (such as int *) now have their nullability taken into account.
  • SE-0046 Function parameters now have consistent labelling across all function parameters. With this update the first parameter declarations will now match the existing behavior of the second and later parameters. This change makes the language simpler.
  • SE-0037 Comments are now treated as whitespace when determining whether an operator is prefix, postfix, or binary.
  • SE-0053 let is no longer accepted as a parameter attribute for functions. The compiler provides a fixit to remove it from the function declaration.
  • SE-0003 var is no longer accepted as a parameter attribute for functions. The compiler provides a fixit to create a shadow copy in the function body.
  • SE-0043 landed, adding the ability to declare variables in multiple patterns in cases. Renamification landed, so the Clang importer imports ObjC symbols substantially differently. Someone should expand on this point.
  • SE-0040 landed, changing attributes from using = in parameters lists to using :, aligning with function call syntax.
  • SE-0034 has renamed the #line directive (which resets the logical source location for diagnostics and debug information) to #sourceLocation.
  • SE-0064 The Objective-C selectors for the getter or setter of a property can now be referenced with #selector.
  • SE-0062: A key-path can now be formed with #keyPath.

New in Swift 2016-02-03a Snapshot (March 25th, 2016)

  • Curried function syntax has been removed, and now produces a compile-time error.

New in Swift 2.2 (January 26th, 2016)

  • Associated types in protocols can now be specified with a new 'associatedtype' declaration, to replace the use of 'typealias': protocol P { associatedtype Ty }. The typealias keyword is still allowed (but deprecated and produces a warning) in Swift 2.2. This warning will become an error in Swift 3.
  • Curried function syntax has been deprecated, and is slated to be removed in Swift 3.
  • The ++ and -- operators have been deprecated, and are slated to be removed in Swift 3.0. As a replacement, please use "x += 1" on integer or floating point types, and "x = x.successor()" on Index types.
  • The operator identifier lexer grammar has been revised to simplify the rules for operators that start with a dot ("."). The new rule is that an operator that starts with a dot may contain other dots in it, but operators that start with some other character may not contain dots. This eliminates a special case for the ..< operator, folding it into a simple and consistent rule.
  • The "C-style for loop", which is spelled for init; comparison; increment {} has been deprecated and is slated for removal in Swift 3.0. See SE-0007 for more information.
  • Three new doc comment fields, namely - keyword:, - recommended: and - recommendedover:, allow Swift users to cooperate with code completion engine to deliver more effective code completion results. The - keyword: field specifies concepts that are not fully manifested in declaration names. - recommended: indicates other declarations are preferred to the one decorated; to the contrary, - recommendedover: indicates the decorated declaration is preferred to those declarations whose names are specified.
  • Designated class initializers declared as failable or throwing may now return nil or throw an error, respectively, before the object has been fully initialized.
  • All slice types now have removeFirst() and removeLast() methods.
  • ArraySlice.removeFirst() now preserves element indices.
  • Global anyGenerator() functions have been changed into initializers on AnyGenerator, making the API more intuitive and idiomatic. They have been deprecated in Swift 2.2, and will be removed in Swift 3.
  • Closures appearing inside generic types and generic methods can now be converted to C function pointers as long as no generic type parameters are referenced in the closure's argument list or body. A conversion of a closure that references generic type parameters now produces a diagnostic instead of crashing. (rdar://problem/22204968)
  • Anonymously-typed members of C structs and unions can now be accessed from Swift. For example, given the following struct 'Pie', the 'crust' and 'filling' members are now imported. Since Swift does not support anonymous structs, these fields are imported as properties named crust and filling having nested types named Pie.__Unnamed_crust and Pie.__Unnamed_filling. (rdar://problem/21683348)
  • Argument labels and parameter names can now be any keyword except var, let, or inout.
  • Tuples (up to arity 6) whose elements are all Comparable or Equatable now implement the full set of comparison/equality operators. The comparison operators are defined in terms of lexicographical order. See SE-0015 for more information.
  • The @objc(SomeName) attribute is now supported on enums and enum cases to rename the generated Objective-C declaration. (rdar://problem/21930334)
  • When referencing a function or initializer, one can provide the complete name, including argument labels.
  • There is a new build configuration function, #if swift(>=x.y), which tests if the current Swift language version is at least x.y. This allows you to conditionally compile code for multiple language versions in the same file, even with different syntax, by deactivating parsing in inactive code blocks.