简体   繁体   English

Xcode9向后兼容Swift 3(或3.1)吗?

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

I've just started using Xcode9 (beta2). 我刚刚开始使用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: 1)对于以下代码:

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 初始化程序'init()'是内部的,不能从默认参数值引用

2) For this code: 2)对于此代码:

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 闭包元组参数'(key:_,value:_)'不支持解构

Both of these caused no problem with Xcode 8.3/Swift 3.1. 这两个都没有引起Xcode 8.3 / Swift 3.1的问题。

I am using Xcode9 without having chosen the option to update to Swift 4. There seems several possibilities: 我使用Xcode9而没有选择更新到Swift 4的选项。似乎有几种可能性:

  1. There are some flags that need to be set to retain Swift 3.1 backwards compatibility 有一些标志需要设置以保持Swift 3.1向后兼容性
  2. Xcode9 is in beta and just isn't ready fully Xcode9处于测试阶段,尚未完全准备就绪
  3. Xcode9 will not be completely backwards compatible to Swift 3.1 Xcode9不会完全向后兼容Swift 3.1

Thoughts? 思考?

Xcode 9与Swift 3和4交叉兼容。但是,你需要使用Swift 3.2,这是Xcode 9的最小值。

You can find, list of languages supported by specific Xcode, from Build Settings of your Xcode Project. 您可以从Xcode项目的Build Settings中找到特定Xcode支持的语言列表。

Here is sample reference, how you can see it: 以下是示例参考,您将如何看待它:

(For Xcode 9, it supports, Swift 3.2 and Swift 4.0) (对于Xcode 9,它支持,Swift 3.2和Swift 4.0)

在此输入图像描述

Here is reference answer, how you can easily switch from Swift 3.0 to 4.0 以下是参考答案,您可以轻松地从Swift 3.0切换到4.0

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM