ReallySmallSoftware / cordova-plugin-firestore

A Google Firebase Firestore plugin to enable realtime synchronisation between app and cloud and automatically handle limited connectivity.
Other
22 stars 10 forks source link

Firebase/Core Problems #12

Open perexlautaro opened 5 years ago

perexlautaro commented 5 years ago

Expected Behavior

Work and compile in ios like in android.

Actual Behavior

Resulting in:

platform :ios, '10.0'
use_frameworks!
target 'XXX' do
        pod 'FBAudienceNetwork', '4.28.1'
        pod 'GoogleMobileAdsMediationFacebook', '4.28.1.1'
        pod 'Firebase/Firestore'
        pod 'GoogleMaps', '~> 2.7.0'
        pod 'SwiftyRSA', '~>  1.5.0'
        pod 'CryptoSwift', '~> 0.13.0'
        pod 'FirebaseMessaging'
        pod 'FirebaseRemoteConfig'
end
$ ionic start testApp blank
$ cd testApp/
$ ionic cordova plugin add cordova-plugin-firestore --save --variable ANDROID_FIREBASE_CORE_VERSION=+ --variable ANDROID_FIREBASE_FIRESTORE_VERSION=17.1.0
$ ionic cordova build ios

Open platforms/ios/MyApp.xcworkspace in xcode and run

Specifications

Cordova:

cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1) Cordova Platforms : android 7.1.4, ios 4.5.5 Cordova Plugins : cordova-plugin-ionic-webview 1.2.1, (and 26 other plugins)

System:

ios-deploy : 1.9.4 NodeJS : v11.1.0 (/usr/local/Cellar/node/11.1.0/bin/node) npm : 6.4.1 OS : macOS Xcode : Xcode 10.1 Build version 10B61

ReallySmallSoftware commented 5 years ago

As you have got as far as compiling and it is falling over at runtime, do you have some example code?

perexlautaro commented 5 years ago

Yes, I created a repo that contains an example app that gets the same error at runtime: Ionic-Firestore-App

perexlautaro commented 5 years ago

I could fix this error:

2019-01-15 12:03:09.150246-0300 XXX[1263:341484] 5.15.0 - [Firebase/Core][I-COR000003] The default Firebase app has not yet been configured. Add `[FIRApp configure];` (`FirebaseApp.configure()` in Swift) to your application initialization. Read more: https://goo.gl/ctyzm8.

The solution was remove this block:

if(![FIRApp defaultApp]) {
    [FIRApp configure];
}

And add:

NSString *filePath = [[NSBundle mainBundle] pathForResource:@"GoogleService-Info" ofType:@"plist"];
// if file is successfully found, use it
if(filePath){
    NSLog(@"GoogleService-Info.plist found, setup: [FIRApp configureWithOptions]");
    // create firebase configure options passing .plist as content
    FIROptions *options = [[FIROptions alloc] initWithContentsOfFile:filePath];   
    // configure FIRApp with options
    [FIRApp configureWithOptions:options];
}
// no .plist found, try default App
if (![FIRApp defaultApp] && !filePath) {
    NSLog(@"GoogleService-Info.plist NOT FOUND, setup: [FIRApp defaultApp]");
    [FIRApp configure];
}

The solution is related to this comment

Trying a little more I found that line: [FIRApp configureWithOptions:options]; (before [FIRApp configure];) crash the app

perexlautaro commented 5 years ago

Any update on this?

ReallySmallSoftware commented 5 years ago

Sorry, I will try and take a look in the next few days, although I would expect the GoogleService-Info.plist to always be present. Is there a reason why it isn't?

perexlautaro commented 5 years ago

No, there is no reason. The GoogleService-Info.plist is always present. Don't worry, when you can. Thanks for answering!