Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firestore is failed to build with Flutter for iOS

I want to add Firestore to Flutter app, and I have problems running it on iOS. I already added this line to pubspec.yaml

cloud_firestore: ^0.6.3

Flutter is updated. Flutter doctor says that I have v0.3.1.

While compiling app for iOS simulator I got this build error

 Xcode's output: ↳     /
Users/*********/.pub-cache/hosted/pub.dartlang.org/firebase_core-0.2.3/ios/Classes/FirebaseCorePlugin.m:7:9:
fatal error: 'Firebase/Firebase.h' file not found
    #import <Firebase/Firebase.h>
        ^~~~~~~~~~~~~~~~~~~~~


 1 error generated

I also run pod update to make sure that it is not issue with cocoapods.

UPDATE

After another research I found that deleting #use_frameworks! from Podfile in iOS folder let's project to compile. But what should be done in case when this can't be deleted?

like image 890
moonvader Avatar asked Jan 29 '26 00:01

moonvader


1 Answers

The update to this gives me enough information to diagnose (hopefully). Flutter wasn't very good at supporting #use_frameworks & swift, but that was fixed fairly recently (mid-april 2018). However, it may not have made it to the beta channel yet at time of writing.

What was going on when #use_frameworks was set previously is that it wasn't linking everything into the right libraries, and a cocoapods bug was stopping it from finding certain files. The newest version of everything uses dynamic linking but has static_framework=true in the podfile for dependencies with static dependencies so that everything they need actually get linked into the right place.

This is fixed & tested on the master branch/channel, but should probably have made it to the dev branch/channel by now.

Here's the steps to makes sure your environment will support the fix, from this other github issue:

  • make sure you have Cocoapods 1.5.0 installed (pod --version should say >= 1.5.0)
  • change any dependencies you have on the firebase_xxx, google_sign_in, or cloud_firestore plugins to the newest versions (look for changelog entries referring to Cocoapods 1.5.0)
  • change your ios/Podfile to the newest version on Flutter master branch (https://github.com/flutter/flutter/tree/master/packages/flutter_tools/templates/cocoapods)
  • delete ios/Podfile.lock and ios/Pods
  • switch to Flutter master (or dev) branch using flutter channel <branch>
  • flutter clean ; flutter run
like image 151
rmtmckenzie Avatar answered Jan 31 '26 08:01

rmtmckenzie



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!