Flutter:由于集成了 Firebase 和 Admob,因此无法构建 iOS 应用程序

Posted

技术标签:

【中文标题】Flutter:由于集成了 Firebase 和 Admob,因此无法构建 iOS 应用程序【英文标题】:Flutter: Failed to build iOS app since integrating firebase and Admob 【发布时间】:2021-04-09 18:24:14 【问题描述】:

我正在使用 AdMob,所以我不得不在我的项目中包含 firebase。 我觉得 Podfile 有问题,但我很陌生,我不知道如何解决这个错误。 在我添加 Admob 之前,该应用程序运行良好。 一开始,我通过添加 Jason 文件而不更改 Podfiles 和应用程序委托数据来集成 firebase。 但是该应用程序总是显示找不到_firapp或某事的错误,所以我做了一些研究并为firebase和admob准备了应用程序委托中的Podfile和行,现在没有任何工作了。

运行应用程序时,日志显示:

Launching lib/main.dart on iPhone 11 Pro Max in debug mode...
Running Xcode build...
Xcode build done.                                           102,8s
Failed to build ios app
Error output from Xcode build:
↳
    2021-01-03 20:31:10.214 xcodebuild[33146:1683247] warning:  The file reference for "Firebase.debug.xcconfig" is a member of multiple groups ("Support Files" and "Support Files"); this indicates a malformed project.  Only the membership in one of the groups will be preserved (but membership in targets will be unaffected).  If you want a reference to the same file in more than one group, please add another reference to the same path.
    2021-01-03 20:31:10.214 xcodebuild[33146:1683247] warning:  The file reference for "Firebase.release.xcconfig" is a member of multiple groups ("Support Files" and "Support Files"); this indicates a malformed project.  Only the membership in one of the groups will be preserved (but membership in targets will be unaffected).  If you want a reference to the same file in more than one group, please add another reference to the same path.
    2021-01-03 20:31:10.218 xcodebuild[33146:1683247] warning:  The file reference for "GoogleUtilities.debug.xcconfig" is a member of multiple groups ("Support Files" and "Support Files"); this indicates a malformed project.  Only the membership in one of the groups will be preserved (but membership in targets will be unaffected).  If you want a reference to the same file in more than one group, please add another reference to the same path.
    2021-01-03 20:31:10.218 xcodebuild[33146:1683247] warning:  The file reference for "GoogleUtilities.release.xcconfig" is a member of multiple groups ("Support Files" and "Support Files"); this indicates a malformed project.  Only the membership in one of the groups will be preserved (but membership in targets will be unaffected).  If you want a reference to the same file in more than one group, please add another reference to the same path.
    2021-01-03 20:32:28.128 xcodebuild[33146:1683564]  DVTAssertions: Warning in /Library/Caches/com.apple.xbs/Sources/DVTiOSFrameworks/DVTiOSFrameworks-17705/DTDeviceKitBase/DTDKRemoteDeviceData.m:371
    Details:  (null) deviceType from fccbabe047ce389d7f1818829974b98ca79ecafb was NULL when -platform called.
    Object:   <DTDKMobileDeviceToken: 0x7fac7d3bdad0>
    Method:   -platform
    Thread:   <NSThread: 0x7fac7a40e4f0>number = 7, name = (null)
    Please file a bug at https://feedbackassistant.apple.com with this warning message and any useful information you can provide.
    ** BUILD FAILED **


Xcode's output:
↳
    GoogleDataTransport-hjetnganqxhhsyasdefxkgubodfu
    In file included from /Users/patrickmeyer/androidStudioProjects/thirty_day_challange_app/ios/Pods/FirebaseCore/FirebaseCore/Sources/FIRHeartbeatInfo.m:17:
    /Users/patrickmeyer/AndroidStudioProjects/thirty_day_challange_app/ios/Pods/FirebaseCore/GoogleUtilities/Logger/Private/GULLogger.h:22:9: fatal error: 'GoogleUtilities/GULLoggerLevel.h' file not found
    #import <GoogleUtilities/GULLoggerLevel.h>
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    1 error generated.
    In file included from /Users/patrickmeyer/AndroidStudioProjects/thirty_day_challange_app/ios/Pods/FirebaseCore/FirebaseCore/Sources/FIRLogger.m:19:
    /Users/patrickmeyer/AndroidStudioProjects/thirty_day_challange_app/ios/Pods/FirebaseCore/GoogleUtilities/Logger/Private/GULLogger.h:22:9: fatal error: 'GoogleUtilities/GULLoggerLevel.h' file not found
    #import <GoogleUtilities/GULLoggerLevel.h>
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    1 error generated.
    GoogleDataTransport-hjetnganqxhhsyasdefxkgubodfu
    note: Using new build system
    note: Building targets in parallel
    note: Planning build
    note: Constructing build description
    warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.3.99. (in target 'FirebaseCore' from project 'Pods')
    warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.3.99. (in target 'FirebaseCoreDiagnostics' from project 'Pods')
    warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.3.99. (in target 'firebase_core' from project 'Pods')
    warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.3.99. (in target 'Firebase' from project 'Pods')
    warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 4.3, but the range of supported deployment target versions is 9.0 to 14.3.99. (in target 'nanopb' from project 'Pods')
    warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.3.99. (in target 'share' from project 'Pods')
    warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.3.99. (in target 'firebase_admob' from project 'Pods')
    warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 6.0, but the range of supported deployment target versions is 9.0 to 14.3.99. (in target 'GoogleInterchangeUtilities' from project 'Pods')
    warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 7.0, but the range of supported deployment target versions is 9.0 to 14.3.99. (in target 'FirebaseInstanceID' from project 'Pods')
    warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 6.0, but the range of supported deployment target versions is 9.0 to 14.3.99. (in target 'GoogleSymbolUtilities' from project 'Pods')
    warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.3.99. (in target 'GoogleAppMeasurement' from project 'Pods')
    warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.3.99. (in target 'GoogleDataTransport' from project 'Pods')
    warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.3.99. (in target 'GoogleUtilities' from project 'Pods')
    warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 7.0, but the range of supported deployment target versions is 9.0 to 14.3.99. (in target 'FirebaseAnalytics' from project 'Pods')
    warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.3.99. (in target 'Flutter' from project 'Pods')
    warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.3.99. (in target 'shared_preferences' from project 'Pods')

Could not build the application for the simulator.
Error launching application on iPhone 11 Pro Max.

我的 AppDelegate.m :

#import "AppDelegate.h"
#import "GeneratedPluginRegistrant.h"

@import Firebase;
@import GoogleMobileAds;

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application
    didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
  [GeneratedPluginRegistrant registerWithRegistry:self];
  // Use Firebase library to configure APIs.
  [FIRApp configure];
  // Initialize the Google Mobile Ads SDK.
    [[GADMobileAds sharedInstance] startWithCompletionHandler:nil];
  // Override point for customization after application launch.
  return [super application:application didFinishLaunchingWithOptions:launchOptions];

@end

还有我的 Podfile:

# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', 
  'Debug' => :debug,
  'Profile' => :release,
  'Release' => :release,


def flutter_root
  generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
  unless File.exist?(generated_xcode_build_settings_path)
    raise "#generated_xcode_build_settings_path must exist. If you're running pod install manually, make sure flutter pub get is executed first"
  end

  File.foreach(generated_xcode_build_settings_path) do |line|
    matches = line.match(/FLUTTER_ROOT\=(.*)/)
    return matches[1].strip if matches
  end
  raise "FLUTTER_ROOT not found in #generated_xcode_build_settings_path. Try deleting Generated.xcconfig, then run flutter pub get"
end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_ios_podfile_setup

target 'Runner' do
  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end

# add the Firebase pod for Google Analytics
pod 'Firebase/Analytics'
# add pods for any other desired Firebase products
# https://firebase.google.com/docs/ios/setup#available-pods

pod 'Google-Mobile-Ads-SDK'

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
  end
end

我的 Flutter Doctor 没有显示任何错误。

【问题讨论】:

【参考方案1】:

似乎pod update成功了。 它现在正在运行。

【讨论】:

以上是关于Flutter:由于集成了 Firebase 和 Admob,因此无法构建 iOS 应用程序的主要内容,如果未能解决你的问题,请参考以下文章

在 AWS Device Farm、Saucelabs、Firebase 测试实验室等中运行 Flutter 集成测试

没有创建 Firebase 应用“[DEFAULT]” - 在 Flutter 和 Firebase 中调用 Firebase.initializeApp()

Firebase 通知 Flutter iOS

由于异常活动,我们已阻止来自此设备的所有请求 - Flutter 应用上的 Firebase

Flutter 应用程序的 Firebase 通知突然停止

用于 Flutter 桌面嵌入的 Firebase 身份验证插件