DEV Community

Akio Yamazaki
Akio Yamazaki

Posted on

I made a Firebase Analytics plugin for iOS with Godot.

Overview

Recently I've been making games with Godot. Mainly for iOS and Android apps.
So, I want to add Firebase Analytics to Android and iOS apps respectively, Android is easy, don't need to change program, just Add repository url to build.gradle and Add google-services.json to the project(It's the same process as normal app development).
However, the iOS version is a bit more complicated because I need to write the program. I looked around for a good plugin, and found that there is no standard plugin that uses this, so I decided to make my own.
Here it is
https://github.com/funseek/godot-ios-firebase-analytics

How to create a plugin

This is described in the official page, so I used this as a reference.
https://docs.godotengine.org/en/stable/tutorials/platform/ios/ios_plugin.html

Usage

git clone

Clone the repository, including the repository for godot itself in the submodule.

git clone --recurse-submodules git@github.com:funseek/godot-ios-firebase-analytics.git
Enter fullscreen mode Exit fullscreen mode

Create a header file for the godot source

./scripts/generate_headers.sh
Enter fullscreen mode Exit fullscreen mode

The header file itself is created quickly, so you don't have to wait for it to finish.

pod install

You can get the Firebase-related files from CocoaPods.

pod install
Enter fullscreen mode Exit fullscreen mode

Create the .a library file.

./scripts/release_static_library.sh 3.4
Enter fullscreen mode Exit fullscreen mode

If you want to specify a different version, you can use the 3.4 version in the SConstruct file. If you want to specify a different version, replace 3.4 in the SConstruct file.

Copy to project

Copy the created .a file to your godot project.

cp bin/release/firebase-analytics/firebase-analytics.*.a $GODOT_HOME/ios/plugins/firebase-analytics/bin/
cp firebase-analytics.gdip $GODOT_HOME/ios/plugins/
Enter fullscreen mode Exit fullscreen mode

Export for iOS

Don't forget to check the Firebase-Analytics box in Plugins.

Image description

Xcode configuration

Use CocoaPods for Xcode, and add the following to your podfile.

pod 'Firebase/Analytics'.
pod 'Firebase/Auth'
pod 'Firebase/Firestore'
Enter fullscreen mode Exit fullscreen mode

The steps to use CocoaPods are as follows.

  1. run pod init (if you are not already using it)
  2. add the above to your Podfile
  3. run pod install
  4. open the project .xcworkspace in Xcode
  5. Copy GoogleService-Info.plist to the project (you can download it from the Firebase administration page).

If it works, you are done!

Plug-ins that depend on external libraries are often loaded by copying each external library, but if you copy and use the dependent libraries for each plug-in, you may get errors when using different versions of the same library (I actually did). So, I think it's better to use CocoaPods to manage all the dependent libraries (personal opinion). Some examples of dependent libraries are Firebase, AdMob, etc.

Others

In addition to the above, I also created the following plugins

A plugin to display the review request dialog
https://github.com/funseek/godot-ios-request-review

Plugin to show ATT dialog
https://github.com/funseek/godot-ios-att

After I wrote this, I realized that it would be easier to use the plug-ins if they were loaded by CocoaPods. I thought. I'll try it next time.

Top comments (0)