App fails when building upon adding Firebase Cloud Messaging Dependency to PubSpec.yaml -Flutter
I have finally figured out the solution. And the solution is to not follow the guidelines on firebase.google.com while creating iOS App in firebase. You should strictly follow the guidelines on https://firebase.flutter.dev/docs/overview/
To recap the steps I took:
- Created a new flutter project
- In pubspec.yaml added firebase_core: "0.7.0" under dependencies. Did pub get
- Browsed to project directory > iOS folder > open projectname.xcworkspace
- Click on Runner and in General copy Bundle Identifier.
- Change iOS version to 10 or later in Development Info in the General Tab
- Paste this Bundle Identifier in "Add Firebase to your iOS app" Step 1 Register
- Click Next and download the GoogleService-Info.plist
- In projectname.xcworkspace click on Runner at the TOP. Right Click and press "Add files to Runner". Browse the GoogleService-Info.plist file. Ensure the "Copy items if needed" checkbox is enabled
- Once done run the project without taking any further steps and it should work fine.
I just created two new projects to ensure it is working before posting here and it works fine. I hope it works for you too.
Aly_ElAshram
Updated on December 19, 2022Comments
-
Aly_ElAshram over 1 year
When I build the app using VScode or the terminal or XCode it runs perfectly without adding the dependency but when I add the dependency to my Pubspec.yaml I get the Following Error:
/ios/Pods/GoogleDataTransport/GoogleDataTransport/GDTCCTLibrary/GDTCCTUploadOperation.m:36:9: fatal error: 'GoogleUtilities/GULURLSessionDataResponse.h' file not found #import <GoogleUtilities/GULURLSessionDataResponse.h> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1 error generated. note: Using new build system note: Building targets in parallel note: Planning build note: Constructing build description Could not build the application for the simulator. Error launching application on iPhone 11. Exited (sigterm)**
**
I Tried Searching here for Solutions couldn't find Any. Previous Solutions I tried were:
- Running Flutter Clean Then Flutter Run (Didn't Work)
- Deleting the Podfile.lock and podfile and .xcworkspace file and Then running pod install in the terminal(didn't work)
- Pod update
here is my flutter doctor Trace:
**[✓] Flutter (Channel stable, 2.0.3, on macOS 11.2 20D64 darwin-x64, locale en-EG) [✗] Android toolchain - develop for Android devices ✗ Unable to locate Android SDK. Install Android Studio from: https://developer.android.com/studio/index.html On first launch it will assist you in installing the Android SDK components. (or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions). If the Android SDK has been installed to a custom location, please use `flutter config --android-sdk` to update to that location. [✓] Xcode - develop for iOS and macOS [✓] Chrome - develop for the web [!] Android Studio (not installed) [✓] Connected device (2 available)**
and here is my PodFile:
# Uncomment this line to define a global platform for your project # platform :ios, '9.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 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
And here is my pubspec.yaml, Yes I'm using an older version of firebase cloud messaging and it's due to dependency conflict between firebase Core and the new Firebase cloud messaging version "^9.0.0"
version: 1.0.0+1 environment: sdk: ">=2.7.0 <3.0.0" dependencies: flutter: sdk: flutter firebase_core: "0.7.0" firebase_auth: ^0.20.0+1 flutter_spinkit: "^4.1.2" google_sign_in: ^4.5.3 connectivity: ^2.0.2 path: any sqflite: ^1.3.2+3 share: ^0.6.5+4 flutter_facebook_login: ^3.0.0 apple_sign_in: ^0.1.0 provider: ^4.0.1 crypto: ^2.1.5 in_app_purchase: ^0.5.1 flutter_email_sender: ^5.0.0 scroll_snap_list: ^0.6.0 firebase_messaging: ^5.1.2 flutter_twitter_login: git: https://github.com/Kiruel/flutter_twitter_login cupertino_icons: ^1.0.0 dev_dependencies: flutter_test: sdk: flutter