gpt4 book ai didi

ios - Xcode 9 Swift 语言版本 (SWIFT_VERSION)

转载 作者:行者123 更新时间:2023-11-30 10:44:32 29 4
gpt4 key购买 nike

我最近将 xcode 更新到版本 9。在此之前,在 Xcode 8.x 中,每当我使用 pod update 时,它都会显示一个更新代码,用于将代码转换为 Swift 3 并执行此操作解决错误。但现在它给了我这个错误:

The “Swift Language Version” (SWIFT_VERSION) build setting must be set to a supported value for targets which use Swift. This setting can be set in the build settings editor.

对于这个错误,我尝试了Build Settings > Swift Language Version,它是 Swift 3.2但由于更新调用重新安装了一些像 Alamofire 这样的 pod,并且它说要安装 Xcode 8.x 以将代码转换为 Swift 3,所以我是否需要安装带有最新 Xcode 的附加版本?如果是,那么如何安装 Xcode 8 和 Xcode 9?

最佳答案

回答您的问题:
您可以从Apple Download Portal下载Xcode 8.x或Download Xcode 8.3.3 (或参见: Where to download older version of Xcode ),如果您有高级开发者帐户(apple id)。您可以在单个 (mac) 系统中安装和使用 Xcode 9 和 Xcode 8.x。 (确保您的命令行工具支持两个版本的 Xcode,以便使用终端(请参阅: How to install 'Command Line Tool' ))

<小时/>

提示:如何将代码迁移到 Xcode 9 兼容的 Swift 版本(Swift 3.2 或 4)
Xcode 9 仅允许从 Swift 3.0 转换/迁移到 Swift 3.2/4.0。因此,如果您项目的 Swift 语言当前版本低于 3.0,那么您必须使用 Xcode 8.x 将代码迁移到 Swift 3 兼容版本。

这是 Xcode 9 在迁移过程中识别低于 3.0 的 Swift 语言时显示的常见错误消息。

enter image description here


Xcode 9 和 Xcode 8 均支持 Swift 3.2。

Project ► (Select Your Project Target) ► Build Settings ► (Type 'swift' in Searchbar) Swift Compiler Language ► Swift Language Version ► Click on Language list to open it.

enter image description here



使用 Xcode 8 将源代码从 Swift 2.0 转换为 3.2,然后继续使用 Xcode 9(Swift 3.2 或 4)。

<小时/>

为了更轻松地迁移您的代码,请按照以下步骤操作:(它将帮助您转换为 Xcode 工具支持的最新版本的 swift)

Xcode: Menus: Edit ▶ Covert ▶ To Current Swift Syntax

enter image description here

关于ios - Xcode 9 Swift 语言版本 (SWIFT_VERSION),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56042746/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com