3

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?

Krunal
  • 77,632
  • 48
  • 245
  • 261
Chris Prince
  • 7,288
  • 2
  • 48
  • 66

2 Answers2

1

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.

pesch
  • 1,976
  • 2
  • 17
  • 29
  • So, `Xcode9 will not be completely backwards compatible to Swift 3.1` looks to be the case. Since AFAIK, Swift 3.2 came out with Xcode 9. – Chris Prince Jul 07 '17 at 02:42
0

You can find, list of languages supported by specific Xcode, from Build Settings of your Xcode Project.

Here is sample reference, how you can see it:

(For Xcode 9, it supports, Swift 3.2 and Swift 4.0)

enter image description here

Here is reference answer, how you can easily switch from Swift 3.0 to 4.0

Krunal
  • 77,632
  • 48
  • 245
  • 261