IOS Podfile中的firebase消息包错误
Posted
技术标签:
【中文标题】IOS Podfile中的firebase消息包错误【英文标题】:firebase messaging package error in IOS Podfile 【发布时间】:2021-12-09 07:14:36 【问题描述】:应用程序工作正常,但是当我添加 firebase 消息包 10.0.0 时,我在控制台中收到错误并且应用程序无法打开。已经尝试过之前文章中提到的许多与此类似的事情,但对我没有任何帮助。已尝试删除/删除 pod 文件和文件夹,然后 repo update ,flutter clean 但仍然遇到此错误并且无法构建应用程序并在启动它时出错。请帮忙..
Xcode's output:
↳
/Users/gagansingh/Desktop/projectApp/ios/Pods/FirebaseMessaging/FirebaseMessaging/Sources/FIRMessagingPubSub.m:229:26: error: definition of 'GULSecureCoding' must be imported from module 'GoogleUtilities.GULSecureCoding' before it is required
NSData *pendingData = [GULSecureCoding archivedDataWithRootObject:topicsList error:&error];
^
In module 'GoogleUtilities' imported from /Users/gagansingh/Desktop/projectApp/ios/Pods/FirebaseMessaging/FirebaseMessaging/Sources/FIRMessagingPubSub.m:20:
/Users/gagansingh/Desktop/projectApp/ios/Pods/GoogleUtilities/GoogleUtilities/Environment/Public/GoogleUtilities/GULSecureCoding.h:22:12: note: definition here is not reachable
@interface GULSecureCoding : NSObject
Podfile:-
# Uncomment this line to define a global platform for your project
platform :ios, '10.0'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
pod 'Google-Mobile-Ads-SDK'
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
use_frameworks!
use_modular_headers!
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
end
end
【问题讨论】:
遇到同样的问题,如有解决办法请更新 检查我在答案中所做的更改并尝试。 【参考方案1】:如果有任何机构试图达到同样的效果。以下是我在 pod 文件中所做的更改。首先删除 Podfile.lock 和 Pods 文件夹,并按照此处所做的那样对 pod 文件进行更改,然后 flutter clean 然后再次运行。您可能会再次遇到错误,因为它找不到 pods 文件夹和 pods file.lock 并且必须自己创建新的。检查这些是否已创建,然后再次运行。在所有这些之前,您必须添加与您在 pubspec.ymal 中添加其他 firebase 包相同版本的 firebase_analytics,无论您是否使用它。
# Uncomment this line to define a global platform for your project
platform :ios, '10.0'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
use_frameworks!
pod 'Google-Mobile-Ads-SDK'
pod 'Firebase/Core'
pod 'Firebase/Crashlytics'
pod 'Firebase/Analytics'
pod 'Firebase/Messaging'
pod 'Firebase/Auth'
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
use_modular_headers!
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
end
end
target 'ImageNotification' do
pod 'Firebase/Messaging'
end
【讨论】:
以上是关于IOS Podfile中的firebase消息包错误的主要内容,如果未能解决你的问题,请参考以下文章
无法在 iOS 中连接 firebase crashlytics
如何从 iOS 中的 Firebase 消息通知中获取主题?