简体   繁体   English

Flutter (iOS) - 在 GeneratedPluginRegistrant.m 中找不到模块“cloud_firestore”

[英]Flutter (iOS) - Module 'cloud_firestore' not found in GeneratedPluginRegistrant.m

I'm a newborn in flutter environment.我是颤振环境中的新生儿。

I was trying to setup a Cloud Firestore connection to my app.我试图设置到我的应用程序的 Cloud Firestore 连接。 I did most of the coding process on VSCode, but after implementing firestore, I tried building in Xcode since I got some error on VSCode.我在 VSCode 上完成了大部分编码过程,但是在实现 firestore 之后,我尝试在 Xcode 中构建,因为我在 VSCode 上遇到了一些错误。

Upon building my app in Xcode 12.5.1 (which I opened using Rosetta), I got this error Error when building app - Module 'cloud_firestore' not found在 Xcode 12.5.1(我使用 Rosetta 打开)中构建我的应用程序时,我在构建应用程序时遇到此错误错误 - 找不到模块“cloud_firestore”

I've make sure to add the dependencies either in Podfile or in my Pubspec.yaml file.我确保在 Podfile 或我的 Pubspec.yaml 文件中添加依赖项。

Here is My podfile and here is my pubspec.yaml dependencies pubspec.yaml dependencies这是我的 podfile ,这是我的 pubspec.yaml 依赖项pubspec.yaml 依赖项

I've tried several things such as:我尝试了几件事,例如:

  1. Deintegrate pod and installing pod again(including deleting the podfile.lock and pods directory and reinstalling the pod again)解体pod重新安装pod(包括删除podfile.lock和pods目录,重新安装pod)

  2. I've tried flutter clean -> flutter pub get -> flutter build ios , but still resulting in the same error.我试过flutter clean -> flutter pub get -> flutter build ios ,但仍然导致同样的错误。

  3. I have imported my GoogleService-Info.plist to my Runner via Xcode and double checking the name.我已通过 Xcode 将我的 GoogleService-Info.plist 导入我的 Runner 并仔细检查名称。

What intrigue me is, I also add Firebase_auth package and it works just fine.令我着迷的是,我还添加了 Firebase_auth 包,它工作得很好。 See the error only showing at the import Cloud Firestore line查看仅在导入 Cloud Firestore 行中显示的错误

Does anyone know how to resolve this error?有谁知道如何解决这个错误? Any help would be very much appreciated.任何帮助将不胜感激。 Thank you so much 🙏非常感谢🙏

可以看到你的iOS项目下已经成功导入cloud_firestore模块了吗?

Finally after days of trying and error, I found a way to work it out..经过几天的尝试和错误,我终于找到了解决方法。

So, I noticed several things that might cause an error when building for iOS.所以,我注意到在为 iOS 构建时可能会导致错误的几件事。

  1. Never run the command pod install manually.切勿手动运行命令pod install

  2. Do not add the line pod install Firebase to your podfile.不要将行pod install Firebase添加到您的 podfile 中。 Instead, just override all of the firebase dependencies using $FirebaseSDKVersion = '8.0.0'相反,只需使用$FirebaseSDKVersion = '8.0.0'覆盖所有 firebase 依赖项

  3. Don't forget to specify your iOS Deployment target on your podfile and match it with the deployment target on your Runner.xcworkspace file (Both in the runner and in the target)不要忘记在你的 podfile 上指定你的 iOS 部署目标,并将它与你的 Runner.xcworkspace 文件中的部署目标相匹配(在运行器和目标中)

So, if you already have a project, here are the steps I recommend, as this works perfectly for me:所以,如果你已经有一个项目,这里是我推荐的步骤,因为这对我来说非常有效:

  1. Delete the Pods directory, the /ios/podfile.lock, and the ios/Flutter/Flutter.podspec删除 Pods 目录、/ios/podfile.lock 和 ios/Flutter/Flutter.podspec

  2. Run pod deintegrate运行pod deintegrate

  3. Delete all of the contents inside your DerivedData folder.. you can run rm -rf ~/Library/Developer/Xcode/DerivedData/*删除 DerivedData 文件夹中的所有内容.. 你可以运行rm -rf ~/Library/Developer/Xcode/DerivedData/*

  4. Run flutter clean运行flutter clean

  5. Run flutter pub get运行flutter pub get

  6. Run flutter build ios .运行flutter build ios Note thas this will also run the pod install command.请注意,这也将运行pod install命令。

  7. Close your editor, and open your Runner.xcworkspace on XCode and run your XCode.关闭编辑器,在 XCode 上打开 Runner.xcworkspace 并运行 XCode。 Clean your build folder.清理您的构建文件夹。 If there's an option to update your project settings, accept it.如果有更新项目设置的选项,请接受它。

You might get several warnings about deprecated functions, but in my case, my app run just fine..您可能会收到一些关于已弃用函数的警告,但就我而言,我的应用程序运行得很好..

I don't know about the details on why it happened, but from what I noticed, Cocoapods have a different version of some of the firebase packages for ios.. I hope someone can explain it..我不知道为什么会发生这种情况的详细信息,但是从我注意到的情况来看,Cocoapods 为 ios 提供了一些不同版本的 firebase 软件包。我希望有人能解释一下。

-- ——

Things to note :注意事项:

  • If build your app on XCode, and then use flutter run either on terminal or VSCode, you would get some warnings like Class AMSupportURLConnectionDelegate is implemented in both .如果在 XCode 上构建您的应用程序,然后在终端或 VSCode 上使用flutter run ,您会收到一些警告,例如Class AMSupportURLConnectionDelegate is implementation in both . So, from my personal experience, I always run my app from XCode.所以,根据我的个人经验,我总是从 XCode 运行我的应用程序。

  • If you use Google Sign In, follow the steps here you don't need to add anything in your podfile.如果您使用 Google Sign In,请按照此处的步骤操作您无需在 podfile 中添加任何内容。

For reference, here is my podfile content.作为参考,这是我的 podfile 内容。

# Uncomment the next line to define a global platform for your project
 # platform :ios, '12.0'

ENV['COCOAPODS_DISABLE_STATS'] = 'true'

$FirebaseSDKVersion = '8.0.0'

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)
    target.build_configurations.each do |config|
     config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'
     config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
    end
  end
end

I hope it works for you!我希望这个对你有用! Goodluck!祝你好运!

Non of the previous solutions worked for me.以前的解决方案都不适合我。 After two days of searching I downgraded cocoapods to an older version that I knew had worked in the past:经过两天的搜索,我将 cocoapods 降级为我知道过去工作过的旧版本:

-COCOAPODS: 1.11.2
+COCOAPODS: 1.10.1

Uninstalled with gem uninstall cocoapods and installed the old version.gem uninstall cocoapods ,安装旧版本。 After that I applied @reneconrad's answer.之后,我应用了@reneconrad 的回答。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Flutter iOS 错误:GeneratedPluginRegistrant.m:致命错误:找不到模块“package_info” - Flutter iOS error: GeneratedPluginRegistrant.m: fatal error: module 'package_info' not found Flutter on IOS:致命错误:找不到模块“cloud_firestore” - Flutter on IOS: fatal error: module 'cloud_firestore' not found Flutter 无法建立在 ios 模块 'cloud_firestore' 未找到 @import cloud_firestore; - Flutter can't build on ios module 'cloud_firestore' not found @import cloud_firestore; Flutter IOS build Xcode GeneratedPluginRegistrant.m 导入错误 - Flutter IOS build Xcode GeneratedPluginRegistrant.m import error 未找到模块“Cloud_Firestore” - XCode - Flutter - Module 'Cloud_Firestore' not found - XCode - Flutter 在颤动中构建 IOS,它显示 GeneratedPluginRegistrant.m Plugin headers not found ex :(#import<firebase_analytics/FirebaseAnalyticsPlugin.h> ) - Build IOS in flutter it's showing GeneratedPluginRegistrant.m Plugin headers not found ex :(#import <firebase_analytics/FirebaseAnalyticsPlugin.h>) Flutter 中的 Firebase cloud_firestore 版本问题 - iOs M1 - Firebase cloud_firestore version issue in Flutter - iOs M1 找不到模块 cloud_firestore - Module cloud_firestore not found 未找到模块“cloud_firestore”:BigSur VM 上的 Flutter - Module 'cloud_firestore' not found: Flutter on BigSur VM Flutter iOS Cloud_FireStore提供错误 - Flutter ios cloud_firestore giving errors
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM