A month of Flutter: configure Firebase Auth for Sign in with Google on iOS

Yesterday I configured Sign in with Google on Android. Today is more of the same but in iOS land.

From the app directory I ran open ios/Runner.xcworkspace to open the iOS project in Xcode. Then in Xcode I selected "Runner" under "Project navigator" in the left sidebar followed by "Runner" under "Targets" in the main content area. Here I set "Bundle identifier" to app.birb.

update Bundle identifier in Xcode

Using the development Firebase project from yesterday, I added a new iOS app using the same bundle ID.

add iOS app to Firebase project

Firebase then prompted me to download a GoogleService-Info.plist file.

download iOS config file

Once downloaded, I dragged the plist file into the Xcode "project navigation" sidebar within the "Runner" directory next to Info.plist. By dragging it into Xcode, it gets registered for inclusion during builds. There isn't any sensitive information in the file but for an open source project it will need to be different for every developer so I'm adding it to .gitignore.

update Bundle identifier in Xcode

I then skipped step three "add Firebase SDK" and step four "add initialization code".

There is one important change to ios/Runner/Info.plist: configuring a CFBundleURLSchemes. The value can be copied from the GoogleServiceInfo.plist file. I would like to not hard code this but I currently don't have a better alternative.

<array>
  <dict>
    <key>CFBundleTypeRole</key>
    <string>Editor</string>
    <key>CFBundleURLSchemes</key>
    <array>
      <!-- Copied from GoogleServices-Info.plist key REVERSED_CLIENT_ID -->
      <string>com.googleusercontent.apps.483795507272-cavro2su6d78ldumt6003lo2krdrb2dd</string>
    </array>
  </dict>
</array>

Starting the app should give Firebase the all set signal.

adding Android app to Firebase project

And the Sign in with Google button still doesn't do anything but maybe tomorrow it really will.

Code changes

Posts in this series

  • A month of Flutter
  • A month of Flutter: create the app
  • A month of Flutter: configuring continuous integration
  • A month of Flutter: continuous linting
  • A month of Flutter: upgrading to 1.0
  • A month of Flutter: initial theme
  • A month of Flutter: no content widget
  • A month of Flutter: a list of posts
  • A month of Flutter: extract post item widget
  • A month of Flutter: post model and mock data
  • A month of Flutter: rendering a ListView with StreamBuilder
  • A month of Flutter: Stream transforms and failing tests
  • A month of Flutter: real faker data
  • A month of Flutter: rendering network images
  • A month of Flutter: FABulous authentication
  • A month of Flutter: configure Firebase Auth for Sign in with Google on Android
  • A month of Flutter: configure Firebase Auth for Sign in with Google on iOS
  • A month of Flutter: Sign in with Google
  • A month of Flutter: mocking Firebase Auth in tests
  • A month of Flutter: delicious welcome snackbar
  • A month of Flutter: navigate to user registration
  • A month of Flutter: user registration form
  • A month of Flutter: testing forms
  • A month of Flutter: setting up Firebase Firestore
  • A month of Flutter: awesome adaptive icons
  • A month of Flutter: set up Firestore rules tests
  • A month of Flutter: Firestore create user rules and tests
  • A month of Flutter: WIP save users to Firestore
  • A month of Flutter: user registration refactor with reactive scoped model
  • A month of Flutter: the real hero animation
  • A month of Flutter: a look back