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

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

问题描述:

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

After creating a new app in Android Studio which is able to build in iOS and run successfully, I add admob_flutter: ^0.3.1 as a dependency in pubspec.yaml, get the packages successfully, then rebuild and straight away it fails to build with error:

Xcode的输出:

===使用配置调试的项目Pod的构建目标admob_flutter调试===
对于使用Swift的目标,必须将 Swift语言版本(SWIFT_VERSION)构建设置设置为支持的值。支持的值为:3.0、4.0、4.2。可以在构建设置编辑器中设置此设置。

Internet上有一些线程可能对此有所帮助,但它们全部大约2岁左右,所以不能确定它们是否是最新的,因此不想乱糟糟的事情。尤其是因为Flutter还是两年前才问世。

There's a few threads around the internet that may help with this but they're all about 2 years old so not really sure if they're current and so don't want to mess around and make things worse. Especially since Flutter only came out two years ago anyway.

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

I faced this issue too. So just create a new Swift file in Runner folder. XCode will redetect your source.

按以下方式编辑Pod文件:

Edit your Pod file as following:

添加 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