Firebase C++ and Cocos2d-x official guide from Google almoust works out of the box

Hi, there already was post about Firebase, but I decided to test myself if it really works :slight_smile:

Spent some time to figure out how to make sample project working , so sharing my instructions:

Firebase sample project repository:

Before u start setup you need to install cocoapods on your Mac. Easiest way to do this is install homebrew package manager ( https://brew.sh/ ) :

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

After installed homebrew cocoapods can be installed with simple command:

brew install cocoapods

If u need to install git u can do same:

brew install git

After u installed cocoapods and having git, make clone of Firebase sample repository:

git clone https://github.com/firebase/cocos2dx-cpp-sample.git

After cloned navigate to folder: cocos2dx-cpp-sample and run command:

./setup_firebase_sample.py Analytics

This script supports only one of this parameters: [‘AdMob’, ‘Analytics’, ‘Auth’, ‘Database’, ‘Invites’, ‘Messaging’, ‘Remote_Config’]

I recommend to start with analytics as it is much easier.

After running that command script will install cocos2d-x, will generate sample project for Analytics and will install POD (frameworks) required for Firebase Analytics.

I didn’t find way yet to install multiple samples at once like Analytics and Admob - it seems script configured to do it only once with one module. So if you want to experiment after Analytics with Admob - you will need again to clone Firebase repository and run pything script to get it configured specifically for Admob.

After running script project will be located under:

cocos2dx-cpp-sample/sample_project/proj.ios_mac

You will need to open inside it:

HelloCpp.xcworkspace not like usually HelloCpp.xcodeproj

After opened project in Xcode u need to change schemas for project:

Press Manage Schemes and enable all schemes to be visible in Xcode. After that switch schema to:
Pods-HelloCpp-Mobile and build it for Generic Device thru Product->Build:

After that u can switch back to HelloCpp-Mobile schema and run it on your device.

If you will not do previous step - Xcode project will complain about missing some libs, like this:

ld: warning: directory not found for option '-L/Users/myuser/Library/Developer/Xcode/DerivedData/HelloCpp-gweazweoevhswmdemtbmybmhsnuv/Build/Products/Debug-iphoneos/GTMOAuth2'
ld: warning: directory not found for option '-L/Users/myuser/Library/Developer/Xcode/DerivedData/HelloCpp-gweazweoevhswmdemtbmybmhsnuv/Build/Products/Debug-iphoneos/GTMSessionFetcher'
ld: warning: directory not found for option '-L/Users/myuser/Library/Developer/Xcode/DerivedData/HelloCpp-gweazweoevhswmdemtbmybmhsnuv/Build/Products/Debug-iphoneos/GoogleAPIClientForREST'
ld: warning: directory not found for option '-L/Users/myuser/Library/Developer/Xcode/DerivedData/HelloCpp-gweazweoevhswmdemtbmybmhsnuv/Build/Products/Debug-iphoneos/GoogleToolboxForMac'
ld: warning: directory not found for option '-L/Users/myuser/Library/Developer/Xcode/DerivedData/HelloCpp-gweazweoevhswmdemtbmybmhsnuv/Build/Products/Debug-iphoneos/Protobuf'
ld: library not found for -lGTMOAuth2
clang: error: linker command failed with exit code 1 (use -v to see invocation)

After u are done :slight_smile: configure project in Firebase console and upload to Classes folder your Firebase config file.

Have a look and let me know if it is clear :slight_smile:

8 Likes