herzbube / littlego

Little Go. An iOS application that lets you play the game of Go on the iPhone or iPad.
https://littlego.herzbube.ch/
Apache License 2.0
140 stars 54 forks source link

Begin migration from Twitter Fabric to Google Firebase #320

Closed herzbube closed 5 years ago

herzbube commented 5 years ago

Little Go uses Crashlytics for crash reporting. When Crashlytics was acquired by Twitter it was integrated into Twitter's Fabric framework. In January 2017, Twitter sold Fabric and Crashlytics (and other stuff) to Google. 1½ years later, in September 2018, Google announced that it will discontinue Fabric and that it will integrate all of its functions into the Firebase developer platform (Wikipedia, Firebase), another of Google's acquisitions (in 2014).

The roadmap for the future of Fabric is presented here (linked page might go away in the future). It essentially states that Fabric will disappear in mid-2019 and that developers should start the migration to Firebase rather sooner than later. Migration is expected to happen in two phases:

  1. Begin the move to Firebase by starting to use Crashlytics in Firebase. No SDK changes are needed yet in this phase. Work on this phase can begin now.
  2. Complete the transition to Firebase by starting to use the new Crashlytics SDK. Work on this phase can begin some time in early 2019.

This issue exists to track work on phase 1 of the migration.

herzbube commented 5 years ago

The tutorial Cannonball’s Journey from Fabric to Firebase in Fabric's documentation is supposed to help with the migration to Firebase by showing what steps were necessary to migrate the Cannonball app.

After going through the tutorial, I must say that its main worth was in that it contains some links into the Firebase documentation. Not sure if Little Go is too special...

Here's my own summary of what I had to do to complete phase 1 of the migration:

New Firebase project

The very first step is to create a new Firebase project for Little Go in the Firebase console.

The "Firebase console" is the Firebase web frontend available under https://console.firebase.google.com/.

A Firebase project is a Google Cloud Platform project that uses Firebase services.

Add Firebase to Little Go

In the Firebase console, start the "Add Firebase to your iOS app" wizard. I did this by clicking the big friendly "Crashlytics" button in the Firebase console, followed by a click on the "iOS" badge.

Step 1 of the wizard: Register the app

Registration information:

Step 2 of the wizard: Add the config file to the project

Step 3 of the wizard: Add the Firebase SDK to the project

Add this line to Podfile:

pod 'Firebase/Core'

Then run

pod install

This not only adds the Firebase SDK but also a number of dependencies to Podfile.lock.

Step 4 of the wizard: Add initialization code

In Prefix.pch replace these lines

#import <Fabric/Fabric.h>
#import <Crashlytics/Crashlytics.h>

with this line:

#import <Firebase.h>`

The wizard recommends to write

@import Firebase;

but in the case of Little Go this would require to change some Xcode project settings, which I am not yet ready to do.

Next, in ApplicationDelegate.mm add this line to the setupCrashReporting() method:

[FIRApp configure];

Step 5 of the wizard: Run the app once to complete the Firebase setup process.

It is sufficient to run the app in the simulator.

Note that if you are stuck in step 5 and the wizard does not react to the app being started, you can go back to step 4 and come back to step 5 to force the wizard to re-check.

Link the Fabric project to the Firebase project

After the wizard completes you are now back on the Firebase console on the "Crashlytics" tab. Do not click the "Set up Crashlytics" button! Instead follow the migration flow, as recommended by the Get started with Firebase Crashlytics guide. The migration flow begins at this Fabric URL: https://fabric.io/firebase_migration.

Step 1 of migration flow: Log in with your Google account

For this to work I had to disable some of my Firefox add-ons (e.g. Ghostery).

Note that at this point you also have to trust Fabric to access your Google account.

Click the "Get started" button once you have logged in successfully.

Step 2 of migration flow: Link the app to Firebase

This step is managed by wizard-like UI. Although the wizard looks nice at first glance, the visual cues it gives in my opinion are a total mess. In the end I simply had to click a large blue button at the bottom of the screen "Link 1 app to Firebase".

Once the link is successfully established you can see Crashlytics information in the Firebase console.

Final changes to the Little Go project

Run

pod update

to update the Fabric and Crashlytics Pods to the newest version:

Next, modify the Crashlytics "Run Script" build phase in the Xcode project. Replace this line that uploads the dSYM files

"${PODS_ROOT}/Fabric.framework/run" "$FABRIC_APIKEY" "$FABRIC_BUILDSECRET"

with this line:

"${PODS_ROOT}/Fabric/run" "$FABRIC_APIKEY" "$FABRIC_BUILDSECRET"

The only change is that the folder of the Fabric pod no longer contains the .framework suffix.

Because Little Go is already ported to Xcode 10, I also had to add the app's built Info.plist location to the build phase's "Input Files" field:

$(BUILT_PRODUCTS_DIR)/$(INFOPLIST_PATH)

The reason for this is explained in the Fabric docs:

Xcode 10 adopts a new build ordering that is independent of the ordered list in the Build Phases of Xcode. Put "$(BUILT_PRODUCTS_DIR)/$(INFOPLIST_PATH)" into your Fabric Run Script’s “Input Files” section to ensure your installation of Fabric goes smoothly.

Test migration

The Fabric docs explain how to generate a test crash. Add this line somewhere in your code where it is executed in reaction to a tap on a button, or some similar user interaction:

[CrashlyticsKit crash];

Build the project, but make sure that the dSYM files are uploaded. In the case of Little Go I had to temporarily modify the build phase run script because Little Go is configured to upload dSYM files only for App Store distribution builds. Note that the upload process occurs in the background and can take several minutes. Check with Activity Monitor app whether a process named uploadDSYM is present. As long as you see this process the upload is still in progress.

Run the project in the simulator, but make sure that Xcode's debugger is not connected. Trigger the test crash, restart the app, then check in the Firebase console whether the crash report shows up.

In the case of Little Go I had to fix another bug (#321) before the test crash report successfully showed up.