草庐IT

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

coder 2023-07-14 原文

我最近将 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 9 安装 Xcode 8?

最佳答案

您问题的答案:
您可以从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 语言时显示的常见错误消息。


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.



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


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

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

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

有关ios - Xcode 9 Swift 语言版本 (SWIFT_VERSION)的更多相关文章

  1. ruby - 如何在 Lion 上安装 Xcode 4.6,需要用 RVM 升级 ruby - 2

    我实际上是在尝试使用RVM在我的OSX10.7.5上更新ruby,并在输入以下命令后:rvminstallruby我得到了以下回复:Searchingforbinaryrubies,thismighttakesometime.Checkingrequirementsforosx.Installingrequirementsforosx.Updatingsystem.......Errorrunning'requirements_osx_brew_update_systemruby-2.0.0-p247',pleaseread/Users/username/.rvm/log/138121

  2. ruby-on-rails - 如何使用 Xcode 4.5.1 在 OSX Lion 10.8.2 上编译 EventMachine gem - 2

    我找遍了所有我能找到的地方,但似乎找不到解决这个问题的办法。我在Lion10.8.2上使用Xcode4.5.1,并尝试为Rails项目运行bundle,但它一直卡在这上面。我正在为Heroku使用Thingem。Bolanos@Jeremys-Mac-mini⦿-1.9.3fishfarm$sudogeminstalleventmachinePassword:Buildingnativeextensions.Thiscouldtakeawhile...ERROR:Errorinstallingeventmachine:ERROR:Failedtobuildgemnativeextens

  3. 使用时 Rubygems 2.0.14 不是线程安全的 bundle 程序安装消息 - RUBYGEMS VERSION : 2. 4.5.1 - 2

    运行bundle安装时,我收到以下消息:Rubygems2.0.14isnotthreadsafe,soyourgemswillbeinstalledoneatatime.UpgradetoRubygems2.1.0orhighertoenableparallelgeminstallation.这很奇怪,因为在我的RubyGems环境中它说我的RubyGems版本是:2.4.5.1(见下文)~/w/Rafftopia❯❯❯gemenvRubyGemsEnvironment:-RUBYGEMSVERSION:2.4.5.1-RUBYVERSION:2.2.5(2016-04-26patc

  4. ruby - session 未创建 : Chrome version must be between - 2

    当使用ruby​​selenium驱动程序驱动chrome时,我得到/home/travis/.rvm/gems/ruby-2.6.2/gems/selenium-webdriver-3.141.5926/lib/selenium/webdriver/remote/response.rb:72:in`assert_ok':sessionnot创建:Chrome版本必须在70和73之间(Selenium::WebDriver::Error::SessionNotCreatedError)如何解决这个问题?降级chrome不是我想做的事。 最佳答案

  5. ruby - 来自 Bundler 的 Fresh Ruby gem - 无法加载我的 version.rb 文件? - 2

    我想制作一个全新的Ruby应用程序,所以我决定使用bundlegemfoo来完成它。这给了我全部:lib/foo/version.rbfoo.rbGemfileRakefilefoo.gemspecREADME.md结构。现在,当我运行rubyfoo.rb时,我得到:`require':cannotloadsuchfile--foo/version(LoadError)foo.rb只是默认值:require'foo/version'moduleFooendgems不能自己跑吗?我希望我不必为了测试而将我的gem包含到示例应用程序中吗? 最佳答案

  6. ruby - 开始使用 MacRuby 和 Xcode 4.2 - 2

    我最近想开始使用MacRuby。我已经安装了Xcode4.2和MacRuby,但显然我遗漏了一些东西。到目前为止,在我发现的每个教程中都说,我必须从Xcode模板中选择“MacRuby应用程序”……但是没有这样的条目可用。我试过0.10和几天前发布的每晚版本。我查看了MacRuby的安装位置,我找到了Xcode3.0的模板……我必须使用这些模板吗?如何将它们导入Xcode4.2?在开始之前,我还想知道,从MacRuby开始是否安全?乍一看,我认为"is",因为有新的MacRuby书籍可用——但MacRuby网站上似乎没有太多事件(去年3月的最后一篇博客文章?)……根据我的经验,这可能是

  7. ruby - 在 Xcode 运行脚本构建阶段使用 rvm 强制指定 Ruby - 2

    在Xcode之外,我使用特定版本的Ruby,使用RVM管理多个Ruby安装。Apple的命令行开发工具将Ruby安装在/usr/bin/ruby并且版本为1.8.7。我通过RVM使用1.9.3。有没有办法强制Xcode在运行其运行脚本构建阶段时使用我的1.9.3安装?我已经尝试将Shell路径设置为我的特定Ruby的完整路径,但这似乎没有什么不同,我的意思是我在1.9.3中安装的特定Gems不可用/在Xcode中运行时对脚本可见。如果我在命令行上通过xcodebuild运行我的项目,运行脚本阶段会使用我的特定Ruby,因为它是从我的shell环境中运行的(即使项目文件中的Shell路径

  8. ruby - rbenv:未安装版本 `2.2.3'(由 RBENV_VERSION 环境变量设置) - 2

    当我运行部署脚本时,出现错误:[cb123fad]rbenv:version`2.2.3'isnotinstalled(setbyRBENV_VERSIONenvironmentvariable)DEBUG[cb123fad](Backtracerestrictedtoimportedtasks)capaborted!SSHKit::Runner::ExecuteError:Exceptionwhileexecutingasdeploy@xx.xx.xx.xx:Exceptionwhileexecutingasdeploy@xx.xx.xx.xx:bundleexitstatus:1b

  9. ruby-on-rails - 警告 : Nokogiri was built against LibXML version 2. 8.0,但已动态加载 2.7.8 - 2

    我在OSXML上的Ruby2.0.0和Rails4配置中遇到了这个问题。我的ArchLinux工作站上没有这个问题。这个警告之所以如此烦人,是因为它破坏了我的Vim插件(SweetVimRspec),因此终止了我的Vim开发工作流程,因为我无法测试。我在这里尝试了所有赞成的解决方案:MacuserandgettingWARNING:NokogiriwasbuiltagainstLibXMLversion2.7.8,buthasdynamicallyloaded2.7.3而且我无法摆脱它(实际上我在nokogiri本身中摆脱了它,但在rspec和railsconsole中根本没有)。

  10. ruby - 在 gem --version 之后运行时获取 "isn' t a Gem::Specification(改为 NilClass) - 2

    $gem--version[/home/rohit/.rvm/gems/ruby-1.9.3-p125@qnrDashboard/specifications/net-ssh-2.5.2.gemspec]isn'taGem::Specification(NilClassinstead).[/home/rohit/.rvm/gems/ruby-1.9.3-p125@qnrDashboard/specifications/net-sftp-2.0.5.gemspec]isn'taGem::Specification(NilClassinstead).[/home/rohit/.rvm/ge

随机推荐