【问题标题】:Flutter ios build fails in xcode 10.1 with swift_versionFlutter ios 构建在带有 swift_version 的 xcode 10.1 中失败
【发布时间】:2018-12-06 09:36:14
【问题描述】:

我正在构建一个颤振应用程序。一切都很好。然后我认为 dart 升级了,突然应用程序的构建失败并出现此错误:

对于使用 Swift 的目标,“Swift 语言版本”(SWIFT_VERSION) 构建设置必须设置为受支持的值。支持的值为:3.0、4.0、4.2。可以在构建设置编辑器中设置此设置。

我没有在 xcode 中看到设置,也不确定是什么导致了这个错误。其他人看到了吗?

【问题讨论】:

标签: flutter


【解决方案1】:

对于其他正在寻找解决方案的人。你需要有高于 10.0 的 XCode 版本才能使用 Swift 4.2。

打开您的podfile 并进行以下更改

target 'Runner' do
  use_frameworks! # <---- // 1st add this right below above line
  ...
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['ENABLE_BITCODE'] = 'NO'
      config.build_settings['SWIFT_VERSION'] = '4.2' # <--- // 2nd add this
    end
  end
end

此后,在终端中使用flutter runMore info

【讨论】:

  • 和我做的一模一样