程序问答   发布时间:2022-06-01  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了firebase 未正确初始化:Googleservice-Info.plist 不在 MacOS 上使用 VScode大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

如何解决firebase 未正确初始化:Googleservice-Info.plist 不在 MacOS 上使用 VScode?

开发过程中遇到firebase 未正确初始化:Googleservice-Info.plist 不在 MacOS 上使用 VScode的问题如何解决?下面主要结合日常开发的经验,给出你关于firebase 未正确初始化:Googleservice-Info.plist 不在 MacOS 上使用 VScode的解决方法建议,希望对你解决firebase 未正确初始化:Googleservice-Info.plist 不在 MacOS 上使用 VScode有所启发或帮助;

我正在使用 macOS Big Sur、Visual studio Code 和当前稳定的 Flutter 版本。

  1. 我已经完成了:
Flutter clean,rm -rf Pods Podfile.lock; 
Flutter pub get; pod init; pod update; 
pod install; turned it off and BACk on; 
pulled it out and blew on it then stuck it BACk in
  1. 我的 Podfile 已针对当前 ios 更新,我已将“Googleservice-Info.pList”文件复制到几乎所有目录,包括 Runner/lib/main、Flutter/ 等。

  2. 我已经多次重新启动我的 mac 和 vs 代码,检查了 pubspec.yaml 的准确性,重新运行冻结时自动生成的文件。

  3. 使用 Visual studio 和 iPhone 12 模拟器从 Xcode 编译 ios 时会发生此错误。

  4. 使用 Visual studio 和 AndroID studio 的 Pixel 3 Emulator 为 androID 编译时,没有发生错误,程序编译/按预期工作。

  5. 我没有在 XCode 上尝试过这个编译 - 我更喜欢在 Mac 上使用 VSCode,并希望留在一个适用于所有平台的开发程序环境中(视觉工作室代码)

  6. 我在编译时收到的错误是:

Launching lib/main.dart on iPhone 12 in deBUG mode...
package:notes2/main.dart:1
Xcode build done.                                           62.0s
7.3.0 - [Firebase/Core][I-COR000012] Could not locate configuration file: 'Googleservice-Info.pList'.
ConnecTing to VM service at ws://127.0.0.1:51910/4RdXrGymG2A=/ws
7.3.0 - [Firebase/Core][I-COR000005] No app has been configured yet.
[VERBOSE-2:ui_dart_state.cc(186)] Unhandled Exception: [core/not-initialized] Firebase has not been correctly initialized. Have you added the "Googleservice-Info.pList" file to the project?
VIEw the iOS Installation documentation for more information: https://firebase.Flutter.dev/docs/installation/ios
#0      MethodChAnnelFirebase.initializeApp
package:firebase_core_platform_interface/…/method_chAnnel/method_chAnnel_firebase.dart:88
<asynchronous suspension>
#1      Firebase.initializeApp
package:firebase_core/src/firebase.dart:41
<asynchronous suspension>
#2      main
package:notes2/main.dart:13
<asynchronous suspension>

我已经彻底阅读了 iOS 安装文档,但它没有说明该文件的放置位置或 Visual studio 代码开发环境的任何环境变量设置。

任何在使用 VSCode 方面有经验的人都将不胜感激。我确定它在 mac 上的 XCode 中运行良好。

我的 Podfile

platform :ios,'14.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

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

我的 pubspec.yaml 文件

name: notes2
description: A new Flutter project.

publish_to: "none" # Remove this line if you wish to publish to pub.dev

version: 1.0.0+1

environment:
  sdk: ">=2.12.0 <3.0.0"

dependencIEs:
  Flutter:
    sdk: Flutter
  another_flushbar: 1.10.17
  cuperTino_icons: 1.0.2
  dfunc: 0.6.2
  firebase_auth: 1.0.1
  firebase_core: 1.0.2
  Flutter_bloc: 7.0.0
  freezed_Annotation: 0.14.1
  get_it: 6.0.0
  Google_sign_in: 5.0.1
  injectable: 1.2.2
  oxIDized: 4.1.0
  uuID: 3.0.2
dev_dependencIEs:
  Flutter_test:
    sdk: Flutter
  build_runner: 1.12.2
  freezed: 0.14.1+1
  injectable_generator: 1.2.2
  lint: 1.5.3

Flutter:

  uses-material-design: true

  assets:
      - Googleservice-Info.pList

解决方法

您应该遵循Flutterfire guide。由于指南向您展示了如何在 Xcode 中执行此操作,因为它需要通过 Xcode 完成,因此您应该使用它而不是 VS 代码。 您无法通过 VS 代码来完成。您仍然可以在 VS 代码中编写项目的其余部分。

接下来,@R_262_8554@ Xcode 将文件添加到项目中(通过文件系统手动添加不会将文件链接到项目)。使用 Xcode,打开项目的 ios/{projectNamE}.xcworkspace 文件。右键单击 Xcode 左侧项目导航中的 Runner 并选择“添加文件”,如下所示:

,

我不知道您是否从 VS 代码中添加了“Googleservice-Info.plist”,但@R_262_8554@ Xcode 添加此文件

这样做:

  • 使用 Xcode 打开文件 /$project_name/ios/Runner.xcworkspace
  • 右键单击 Runner 文件夹
  • 点击向 Runner 添加文件。
  • 选择“Googleservice-Info.plist”文件并点击添加。

Xcode screen shoot

firebase 未正确初始化:Googleservice-Info.plist 不在 MacOS 上使用 VScode

大佬总结

以上是大佬教程为你收集整理的firebase 未正确初始化:Googleservice-Info.plist 不在 MacOS 上使用 VScode全部内容,希望文章能够帮你解决firebase 未正确初始化:Googleservice-Info.plist 不在 MacOS 上使用 VScode所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。