From f656e5bb5498fe957cc9f29fa11dfa0936d7725c Mon Sep 17 00:00:00 2001 From: Morgan Chen Date: Mon, 31 Aug 2020 13:31:02 -0700 Subject: [PATCH 1/4] Add snippet for getting Firestore instance in cpp --- firestore/ios/firestore-snippets-cpp/AppDelegate.mm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/firestore/ios/firestore-snippets-cpp/AppDelegate.mm b/firestore/ios/firestore-snippets-cpp/AppDelegate.mm index b049fbc..752d3cd 100644 --- a/firestore/ios/firestore-snippets-cpp/AppDelegate.mm +++ b/firestore/ios/firestore-snippets-cpp/AppDelegate.mm @@ -17,6 +17,7 @@ #import "AppDelegate.h" #import #include "firebase/app.h" +#include "firebase/firestore.h" @interface AppDelegate () @@ -24,10 +25,15 @@ @interface AppDelegate () @implementation AppDelegate - - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [FIRApp configure]; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunused-variable" + // [START get_firestore_instance] firebase::App::Create(); + auto db = firebase::firestore::Firestore::GetInstance(); + // [END get_firestore_instance] +#pragma clang diagnostic pop return YES; } From ca293e31f6ab469dd00af8f054da97b5b1cce509 Mon Sep 17 00:00:00 2001 From: Morgan Chen Date: Mon, 31 Aug 2020 13:45:20 -0700 Subject: [PATCH 2/4] fix build --- .github/workflows/firestore-ios.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/firestore-ios.yml b/.github/workflows/firestore-ios.yml index 9d03ec2..a4b63ad 100644 --- a/.github/workflows/firestore-ios.yml +++ b/.github/workflows/firestore-ios.yml @@ -15,7 +15,7 @@ jobs: runs-on: macOS-latest strategy: matrix: - destination: ['platform=iOS Simulator,OS=13.5,name=iPhone 11'] + destination: ['platform=iOS Simulator,OS=latest,name=iPhone 11'] steps: - name: Checkout uses: actions/checkout@master From c06eb5e8d4d583def111491eb3e706b1605af00d Mon Sep 17 00:00:00 2001 From: Morgan Chen Date: Tue, 1 Sep 2020 13:08:21 -0700 Subject: [PATCH 3/4] address code review --- firestore/ios/firestore-snippets-cpp/AppDelegate.mm | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/firestore/ios/firestore-snippets-cpp/AppDelegate.mm b/firestore/ios/firestore-snippets-cpp/AppDelegate.mm index 752d3cd..0b19a38 100644 --- a/firestore/ios/firestore-snippets-cpp/AppDelegate.mm +++ b/firestore/ios/firestore-snippets-cpp/AppDelegate.mm @@ -19,6 +19,9 @@ #include "firebase/app.h" #include "firebase/firestore.h" +using firebase::App; +using firebase::firestore::Firestore; + @interface AppDelegate () @end @@ -27,13 +30,12 @@ @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [FIRApp configure]; -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wunused-variable" // [START get_firestore_instance] - firebase::App::Create(); - auto db = firebase::firestore::Firestore::GetInstance(); + // Make sure the call to `Create()` happens some time before you call Firestore::GetInstance(). + App::Create(); + Firestore * db = Firestore::GetInstance(); // [END get_firestore_instance] -#pragma clang diagnostic pop + (void)db; // suppress unused variable warning return YES; } From 54b585e14dcfc477531835a3ec959fd6a54b95f8 Mon Sep 17 00:00:00 2001 From: Morgan Chen Date: Tue, 1 Sep 2020 14:21:05 -0700 Subject: [PATCH 4/4] style --- firestore/ios/firestore-snippets-cpp/AppDelegate.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firestore/ios/firestore-snippets-cpp/AppDelegate.mm b/firestore/ios/firestore-snippets-cpp/AppDelegate.mm index 0b19a38..3a61ab5 100644 --- a/firestore/ios/firestore-snippets-cpp/AppDelegate.mm +++ b/firestore/ios/firestore-snippets-cpp/AppDelegate.mm @@ -33,7 +33,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( // [START get_firestore_instance] // Make sure the call to `Create()` happens some time before you call Firestore::GetInstance(). App::Create(); - Firestore * db = Firestore::GetInstance(); + Firestore* db = Firestore::GetInstance(); // [END get_firestore_instance] (void)db; // suppress unused variable warning return YES;