Skip to content

Firebase Setup

Thomas Groechel edited this page Nov 24, 2021 · 16 revisions

Most current (Tom)

Adding Firebase Unity Packages to Allow for Local Unity Development

  1. Open up MoveToCode Unity project if you have not already
  2. Download the Firebase zip folder from here (uses 8.5 at time of writing) and unzip the file.
  3. Use Unity's menu for Assets -> Import Package -> Custom Package... and navigate to the dotnet4 folder from the zip file. You will need to import the following:
    1. FirebaseFirestore.unitypackage
    2. FirebaseStorage.unitypackage
    3. FirebaseAuth.unitypackage (only needed if deploying/writing to FireStore)
  4. Do not enable analytics and you can accept all proposed deletions of obsolete files
  5. You may need to allow permissions for firebase 8.5 cpa or something along those lines, open up your security panel on the mac while Unity is yelling and you and find the "allow firebase" (I forget where it is but if you find it/figure this out please add a picture)
  6. You should be able to hit play now :)
  7. If deploying to phones, you may need to do something for android resolver, not sure how I did it but it fixed; You will need your openjdk to reference correctloy which means you have to uncheck the box in external editor -> oopen jdk and it should automatically be found and then just leave it these are terrible instructions that I will come back to and be very sad

Adding Firebase to Project

  1. Include “Assets/Data” and “Assets/Firebase” into .gitignore if not there yet. This will ignore some Firebase files that are too large to be pushed to GitHub.
  2. If you are planning on using MoveToCode for your own purposes, create a new Firebase project here, following the given steps on the Firebase console.
  3. Import the SDK setup and configuration files, google-services.json for Android and GoogleService-Info.plist for iOS, into your Unity Assets folder. Create a Data folder under Assets and place the two files there. Note: It is not necessary to create a separate folder under Assets as long as the configuration files are under Assets. It is also recommended to not include those files in your GitHub repository.
  4. Reopen your Unity project to allow changes to execute.
  5. Download Firebase Unity SDK zip file from here and unzip the file.
  6. In Unity project, go to Assets->Import Package->Custom Package. Import any desired Firebase packages. This particular Unity project uses Firebase Storage from the dotnet4 folder.
  7. If prompted, enable Analytics for External Dependency Manager.

Troubleshooting/Common Errors

  • If you receive the error "Generation of the Firebase Android resource file google-services.xml from Assets/Data/GoogleService-Info.plist failed," go to your Firebase project and create a Realtime Database. Reimport the google-services.json and GoogleService-Info.plist files by downloading them again from the Firebase console and replace them in the Assets folder.
  • Make sure your project identifiers for your Firebase project correctly matches your bundle identifiers for iOS and Android on Unity.
  • When pushing to GitHub, if you receive an error about large files and potentially not being able to commit further changes, make sure you have added Firebase to .gitignore. It is also suggested to .gitignore your configuration files if you want others to set up their own Firebase project to host its configuration and data.
  • When building for iOS, if your app could not locate configuration file: 'GoogleService-Info.plist', which is needed for your Firebase project, make sure you add 'GoogleService-Info.plist' to your Xcode build folder (under the resources folder) and double click on that file and make sure your project is included on the Target Membership. Refer to this issue for more info.