Getting Started

You can clone the repo with the following command:

git clone https://github.com/firebase/firebase-unity-sdk.git

Prerequisites

The prerequisites for firebase cpp are required. Please install the following packages outlined in README.md for firebase cpp.

The following prerequisites are required for all platforms. Be sure to add any directories to your PATH as needed.

  • CMake version 3.13.3, or newer.
  • Mono version 5 or newer.
  • Unity version 5 or newer.
  • Swig3 version 3.0.6 or newer (Not version 4 though).

Prerequisites for Windows

On windows, to work around path length issues with google unity resolver enable long path support in git:

git config --system core.longpaths true

Prerequisites for Mac

Home brew can be used to install required dependencies:

# https://github.com/protocolbuffers/protobuf/blob/master/kokoro/macos/prepare_build_macos_rc#L20
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
source $HOME/.rvm/scripts/rvm
brew install cmake protobuf python2 mono swig@3
sudo chown -R $(whoami) /usr/local

export PATH="/usr/local/opt/swig@3/bin:$PATH"

Building

The build uses CMake to generate the necessary build files, and supports out of source builds.

The following CMake options are avaliable:

  • FIREBASE_INCLUDE_UNITY: Build for unity only (no mono support)
  • FIREBASE_INCLUDE_MONO: Build for mono only (no unity support)
  • FIREBASE_UNI_LIBRARY: Build all native modules as one dynamic lib
  • FIREBASE_CPP_SDK_DIR: Local path to firebase cpp
  • FIREBASE_UNITY_SDK_VERSION: Set version string of firebase unity package
  • UNITY_ROOT_DIR: Local path to Unity's installation directory (path should end with version number)
  • MONO_DIR: Local path to mono's xbuild executable directory
  • OPENSSL_ROOT_DIR: Open ssl root directory
  • PROTOBUF_SRC_ROOT_FOLDER: Protobuf root directory

Note:
   UNITY_ROOT_DIR is a recommended setting for building unity, else CMake will make an effort to auto find unity.

Note:
   On windows, MONO_DIR is a required setting.

Example build command for linux:

mkdir build && cd build
cmake .. -DFIREBASE_INCLUDE_MONO=ON -DFIREBASE_CPP_SDK_DIR=../../firebase-cpp-sdk
make -j 8

Note:
   There are build helper scripts in the root folder that will build the most common variants and can be used as examples on how to build firebase unity.

Building for iOS

CMake needs an extra argument specifing the tool chain to use:

-DCMAKE_TOOLCHAIN_FILE=../cmake/unity_ios.cmake -G Xcode

Building for Android

Run script ./build_android.sh on linux machine.

Unity Package Command

CPack is used to generate platform zip files with the same folder structure of the Unity plugin. Once each platform zip file is built, run unity packaging tool to generate a .unitypackage file.

cd build
cpack .
cd ../unity_packer
python export_unity_package.py --config_file=exports.json --guids_file=guids.json --assets_dir=.. --assets_zip=../build/*.zip --output_dir=../build/