【发布时间】:2021-06-22 01:29:19
【问题描述】:
我正在使用 macOS Big Sur、Visual Studio Code 和当前稳定的 Flutter 版本。
- 我已经完成了:
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
-
我的 Podfile 已针对当前 ios 进行了更新,并且我已将“GoogleService-Info.plist”文件复制到几乎每个目录,包括 Runner/lib/main、Flutter/ 等。
-
我已经多次重启我的 mac 和 vs 代码,检查了 pubspec.yaml 的准确性,重新运行冻结的自动生成的文件。
-
使用 Visual Studio 和 Xcode 中的 iPhone 12 模拟器为 ios 编译时会出现此错误。
-
使用 Visual Studio 和 Android Studio 中的 Pixel 3 Emulator 为 android 编译时,不会发生错误,并且程序按预期编译/工作。
-
我没有在 XCode 上尝试过这种编译 - 我更喜欢在 Mac 上使用 VSCode,并希望留在一个适用于所有平台的开发程序环境中(Visual Studio 代码)
-
我在编译时收到的错误是:
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 中运行良好。
我的播客文件
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
【问题讨论】:
-
我建议您熟悉 Xcode,因为它会在未来带来好处:修改
.plist文件(尽管您也可以使用 ProperTree),Xcode 在其 IDE 中公开的其他隐藏配置文件。我第一次学习 React Native 时也有同样的想法,我想留在 VS Code 中,不敢尝试 Xcode。特别是在这种情况下,您可能会发现它在 Xcode 上也不起作用,并且可能会发现其他有用的错误消息。 -
谢谢。 Visual Studio Code 是一个很好的系统。我也一直在研究 InteilliJ,但现在会坚持使用 VSCode。最坏的情况是,我只会为 android 编译,因为这是一个更符合我个人经验的项目。但是我想知道在 VSCode 上解决这个问题的方法。
标签: ios firebase flutter dart visual-studio-code