Load Firebase configuration

Instead of committing the Firebase config files to your repository, you can upload them to Codemagic as environment variables and reference them in a custom script. Note that the Firebase config file (google-services.json for Android or GoogleService-Info.plist for iOS) must be Base64-encoded.

  1. Save your Firebase config files as environment variables, e.g. ANDROID_FIREBASE_SECRET and IOS_FIREBASE_SECRET. Make sure to check Secure.

  2. Add the following pre-build script echoing your variables to load the Firebase configuration in Codemagic.

    #!/usr/bin/env sh
    
    set -e # exit on first failed commandset
    
    echo $ANDROID_FIREBASE_SECRET | base64 --decode > $FCI_BUILD_DIR/android/app/google-services.json
    echo $IOS_FIREBASE_SECRET | base64 --decode > $FCI_BUILD_DIR/ios/Runner/GoogleService-Info.plist
    

For more details about using base64 and loading the Firebase configuration in Codemagic, see the step-by-step guide here.