|
| 1 | +# Overview |
| 2 | + |
| 3 | +This describes how Firestore Unity SDK works, and how to develop and test |
| 4 | +the SDK, targeting desktop/Android/iOS. |
| 5 | + |
| 6 | +# Prerequisites |
| 7 | + |
| 8 | +Building the Unity SDK requires building the underlying C++ SDK. Refer to |
| 9 | +[][this doc] for what the prerequisites are. |
| 10 | + |
| 11 | +On top of above, you also need Unity installed (obviously). If you use an |
| 12 | +apple silicon machine as host, be sure to install the right version of |
| 13 | +Unity! |
| 14 | + |
| 15 | +# Building Firestore Unity SDK |
| 16 | + |
| 17 | +Building Firestore into Unity Packages is a very involved process, mixed with |
| 18 | +multiple build tools working together. Therefore, we will rely on Python scripts |
| 19 | +to automate the process. The scripts live under `$REPO_ROOT/scripts/build_scripts`. |
| 20 | + |
| 21 | +```zsh |
| 22 | +# all scripts are run from the repo root. |
| 23 | + |
| 24 | +# Building for Mac. The build tools will try to find Unity automatically |
| 25 | +python scripts/build_scripts/build_zips.py -platform=macos -targets=auth -targets=firestore -use_boringssl |
| 26 | + |
| 27 | +# If above does not work, try specify Unity path direcly |
| 28 | +python scripts/build_scripts/build_zips.py -platform=macos -unity_root=<PATH_TO_UNITY> -targets=auth -targets=firestore -use_boringssl |
| 29 | + |
| 30 | +# Building for Android |
| 31 | +python scripts/build_scripts/build_zips.py -platform=android -targets=auth -targets=firestore -use_boringssl |
| 32 | + |
| 33 | +# Building for iOS. Incremental build for iOS is broken, so we use clean_build here. |
| 34 | +python scripts/build_scripts/build_zips.py -platform=android -targets=auth -targets=firestore -use_boringssl -clean_build |
| 35 | + |
| 36 | +# Other supported platforms are tvos,linux,windows |
| 37 | +``` |
| 38 | + |
| 39 | +After running above commands, some zip files for each platform are created under |
| 40 | +`$PLATFORM_unity` directories. Run below to put all of them into Unity packages: |
| 41 | + |
| 42 | +```zsh |
| 43 | +# Built Unity packages for all platforms are stored under ./package_dir |
| 44 | +python scripts/build_scripts/zips_to_packages.py --output package_dir |
| 45 | +``` |
| 46 | + |
| 47 | +# Running Firestore Desktop TestApp |
| 48 | + |
| 49 | +Test app for Firestore is under `firestore/testapp`, we need to copy a |
| 50 | +`google-services.json` or `GoogleServices-Info.plist` to `firestore/testapp/Assets/Firebase/Sample/Firestore` |
| 51 | +before we can run the test app. |
| 52 | + |
| 53 | +The testapp depends on a custom test runner, which is needs to be copied over unfortunately: |
| 54 | + |
| 55 | +```zsh |
| 56 | +cp ./scripts/gha/integration_testing/automated_testapp/AutomatedTestRunner.cs firestore/testapp/Assets/Firebase/Sample/ |
| 57 | +cp -r ./scripts/gha/integration_testing/automated_testapp/ftl_testapp_files firestore/testapp/Assets/Firebase/Sample/ |
| 58 | +``` |
| 59 | + |
| 60 | +To run the test app, open `firestore/testapp` from Unity Editor, and load the Unity packages we built above. |
| 61 | +Then open up `firestore/testapp/Assets/Firebase/Sample/Firestore/MainSceneAutomated.unity`, you should be |
| 62 | +able to run this scene which in turn runs all integration tests for Firestore. |
| 63 | + |
| 64 | +# Running Firestore Android TestApp |
| 65 | + |
| 66 | +You *probably* need to use `IL2CPP` as scripting backend instead of `Mono` for Android. To do this, |
| 67 | +you can go to `Edit->Project Setting->Player->Android->Scripting Backend` and select `IL2CPP`. |
| 68 | + |
| 69 | +You also need to turn on `minification` under on the same setting page, by turning on `R8` under `publish |
| 70 | +settings`. |
| 71 | + |
| 72 | +To run the Android testapp, go to `File->Build Settings`, select `Android` then click `Switch Platform`. After |
| 73 | +assets are loaded, click `Build and Run`. |
| 74 | + |
| 75 | +# Running Firestore iOS TestApp |
| 76 | + |
| 77 | +Similarly for iOS, go to `File-Build Settings` and select `iOS`. After you click `Build and Run`, it will prompt |
| 78 | +you to select a directory to save generated code and XCode project. |
| 79 | + |
| 80 | +After the code generation is done, go under the directory, and run `pod install` to generate |
| 81 | +a `xcworkspace`, then open it via `XCode`. From `XCode` you should be able to sign the testapp, build and run/debug |
| 82 | +the app with an actual iOS device, or as an iPad App on an Apple Silicon mac. |
0 commit comments