Flutter Admob软件包使我的应用无法构建

时间:2019-07-11 10:27:18

标签: flutter dart admob

在Android Studio中创建了一个可以在iOS中构建并成功运行的新应用之后,我在pubspec.yaml中将admob_flutter: ^0.3.1作为依赖项添加,成功获取软件包,然后重新构建并立即失败生成错误:

Xcode's output: ↳ === BUILD TARGET admob_flutter 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. Supported values are: 3.0, 4.0, 4.2. This setting can be set in the build settings editor.

互联网上有一些线程可能对此有所帮助,但是它们都已经使用了2年左右,因此不能确定它们是否是最新的,因此也不想弄乱它并使情况变得更糟。尤其是因为Flutter两年前才问世。

1 个答案:

答案 0 :(得分:2)

我也遇到了这个问题。因此,只需在Runner文件夹中创建一个新的Swift文件。 XCode将重新检测您的来源。

按如下所示编辑您的Pod文件:

像这样添加use_frameworks!

target 'Runner' do
  use_frameworks!
  # Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
  # referring to absolute paths on developers' machines.
  system('rm -rf .symlinks')
  system('mkdir -p .symlinks/plugins')

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.1' # add this line
    end
  end
end