颤动 - SWIFT_VERSION必须设置为支持的值

时间:2018-05-22 01:27:23

标签: ios flutter

尝试使用库simple_permission,修复了pod错误,这就出现了,不知道如何继续。

在构建设置中没有swift版本的设置,我尝试添加它,但它没有用。

Launching lib/main.dart on iPhone X in debug mode...
Skipping compilation. Fingerprint match.
Running Xcode clean...
Starting Xcode build...
Xcode build done.
Failed to build iOS app
Error output from Xcode build:
↳
** BUILD FAILED **

Xcode's output:
↳
=== BUILD TARGET simple_permissions OF PROJECT Pods WITH CONFIGURATION             Debug ===
    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.
Could not build the application for the simulator.
Error launching application on iPhone X.

6 个答案:

答案 0 :(得分:14)

选中this answer

使用Swift对插件的iOS部分进行编码后,您必须对ios/Podfile进行更改。您必须添加use_frameworks!config.build_settings['SWIFT_VERSION'] = '4.1'

target 'Runner' do
  use_frameworks!  # required by simple_permission
  ...
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['SWIFT_VERSION'] = '4.1'  # required by simple_permission
      config.build_settings['ENABLE_BITCODE'] = 'NO'
    end
  end
end

您可以检查将需要哪个SWIFT_VERSION,在that issue中,该问题已使用3.2解决。在我发布的答案中,建议使用4.1,但4.0也可以。

答案 1 :(得分:2)

看看这个问题: https://github.com/flutter/flutter/issues/16049

它帮助我完成了没有添加快速功能的项目,然后添加了地理定位插件。

答案 2 :(得分:2)

  

在这种情况下,必须创建桥接头。

     
      
  1. 使用XCode打开项目。然后选择文件->新建->文件-> Swift文件。创建swift时将显示一个对话框   文件(由于该文件被删除,因此可以使用任何名称。)。 XCode将   询问您是否要创建桥接标题,请单击“是”。 (它是   重要步骤)

  2.   
  3. 确保您具有use_frameworks!在Runner块中的ios / Podfile中。

  4.   
  5. 确保在XCode->构建设置中选择了SWIFT_VERSION 4.2

  6.   
  7. 拍打干净

  8.   
  9. 转到您的ios文件夹,删除Podfile.lock和Pods文件夹,然后执行pod install --repo-update

  10.   

答案 3 :(得分:1)

通过在项目中创建一个空的swift文件修复。

答案 4 :(得分:0)

在其他答案不适合您的奇怪情况下,请使用pre_install,例如:

pre_install do |installer|
  installer.analysis_result.specifications.each do |s|
    s.swift_version = '4.2' unless s.swift_version
  end
end

上面的答案和这个答案的组合肯定会解决这个问题。

答案 5 :(得分:0)

将此添加到文件ios / XX.podspec

s.swift_versions = ['4.0', '4.2', '5.0']

这将消除错误。