Reputation: 317
I'm using macOS Big Sur, Visual Studio Code with the current stable Flutter release.
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
My Podfile is updated for current ios and I've copied the 'GoogleService-Info.plist' file to just about every directory including Runner/ lib/ main, Flutter/ etc.
I've restarted my mac and vs code several times, checked pubspec.yaml for accuracy, rerun the autogenerated files from the freeze.
This error occurs when compiling for ios using Visual Studio and the iPhone 12 simulator from Xcode.
No error occurs and the program compiles/works as expected when compiling for android using Visual Studio and the Pixel 3 Emulator from Android Studio.
I have not tried this compile on XCode - I prefer using VSCode on Mac and would like to stay in one development program environment for all platforms (visual studio code)
The error I am receiving at compile time is:
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>
I have thoroughly gone through the iOS Installation documentation and it says nothing about where to put this file or any environmental variable settings for the Visual Studio code development environment.
Anyone's input that has experience in getting this working with VSCode would be appreciated. I'm sure it works fine in XCode on mac.
My 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
My pubspec.yaml file
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
Upvotes: 3
Views: 6837
Reputation: 28642
You should follow the Flutterfire guide. Since the guide shows you how to do it in Xcode because it needs to be done via Xcode, you should use that instead of VS code. You cannot do it through VS code. You can still code the rest of your project in VS code.
Next you must add the file to the project using Xcode (adding manually via the filesystem won't link the file to the project). Using Xcode, open the project's ios/{projectName}.xcworkspace file. Right click Runner from the left-hand side project navigation within Xcode and select "Add files", as seen below:
Upvotes: 2
Reputation: 302
I don't know if you add the 'GoogleService-Info.plist' from VS code but you must add this file using Xcode
to do that:
Upvotes: 7