Flutter:firebase_admob 构建在 Xcode 中失败 颤振医生

问题描述

我在 Xcode 中归档我的项目时遇到问题,它失败并抛出错误Module 'firebase_admob' not found

  1. 构建项目:$Flutter build ios
  2. 选择产品 > 存档

enter image description here

此外,我还必须将 Google-Mobile-Ads-SDK 版本从最新的 8.0.0 回滚到 7.69.0 才能使 $Flutter build ios 像所描述的那样工作 here

我已经清理并更新了 Pod:

$Flutter clean
$rm ios/podfile.lock
$rm ios/podfile
$pod update
$Flutter pub get

我在 12.0 和 Xcode 设置中将目标版本设置为 Podfile

目前我可以使用 $Flutter build ios 命令构建我的项目,但我无法将其存档在 Xcode 中以供进一步分发。

颤振医生

[✓] Flutter (Channel stable,1.22.6,on Mac OS X 10.15.7 19H2 darwin-x64,locale ru-RU)
    • Flutter version 1.22.6 at /Users/bob/Documents/Projects/Flutter/Flutter
    • Framework revision 9b2d32b605 (3 weeks ago),2021-01-22 14:36:39 -0800
    • Engine revision 2f0af37152
    • Dart version 2.10.5

 
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.1)
    • Android SDK at /Users/bob/Library/Android/sdk
    • Platform android-29,build-tools 29.0.1
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 12.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.3,Build version 12C33
    • CocoaPods version 1.10.1

[✓] Android Studio (version 3.4)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin installed
    • Dart plugin version 201.9245
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)

[✓] VS Code (version 1.53.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.19.0

[!] Connected device
    ! No devices available

! Doctor found issues in 1 category.
Dart SDK 2.10.5
Flutter SDK 1.22.6
app 1.0.0+1

dependencies:
- cupertino_icons 1.0.0
- firebase_admob 0.11.0+1 [Meta Flutter firebase_core]
- firebase_core 0.7.0 [firebase_core_platform_interface Flutter quiver Meta firebase_core_web]

解决方法

解决此问题的一种方法是构建 ipa 文件。您必须将 Flutter 的频道更改为 betamaster 并升级到最新版本:

$flutter channel beta
$flutter upgrade

那么你应该使用构建工具的新功能: $flutter build ipa

它会在您的项目文件夹中生成存档:<app_name>/build/ios/archive/<provisioning_profile_name>.xcarchive

因此,您可以使用 Xcode 打开生成的存档(即 My Test App.xcarchive),然后像往常一样对其进行验证并上传到 AppStore Connect。