Search code examples
swiftxcodeswift4xcode9xcode9-beta

Is Xcode9 backwards compatible to Swift 3 (or 3.1)?


I've just started using Xcode9 (beta2). My understanding was that it wouldn't force me to immediately change my code. However, I'm getting a build errors coming up with a library I'm using (Gloss):

1) For the following code:

public func valueForKeyPath(keyPath: String, withDelimiter delimiter: String = GlossKeyPathDelimiter, logger: Logger = GlossLogger()) -> Any? {

I get:

Initializer 'init()' is internal and cannot be referenced from a default argument value

2) For this code:

internal func flatMap<KeyPrime : Hashable, ValuePrime>(_ transform: (Key, Value) throws -> (KeyPrime, ValuePrime)?) rethrows -> [KeyPrime : ValuePrime] {
    return Dictionary<KeyPrime,ValuePrime>(elements: try flatMap({ (key, value) in
        return try transform(key, value)
    }))
}

I'm getting:

Closure tuple parameter '(key: _, value: _)' does not support destructuring

Both of these caused no problem with Xcode 8.3/Swift 3.1.

I am using Xcode9 without having chosen the option to update to Swift 4. There seems several possibilities:

  1. There are some flags that need to be set to retain Swift 3.1 backwards compatibility
  2. Xcode9 is in beta and just isn't ready fully
  3. Xcode9 will not be completely backwards compatible to Swift 3.1

Thoughts?


Solution

  • Xcode 9 is cross compatible with Swift 3 and 4. However, you need to be on Swift 3.2 which is the minimum for Xcode 9.