Godot Engine

Integration Godot SDK

The DevToDev SDK extends the Godot engine in a modular way and supports platforms: MacOS, iOS, Android.

Requirements

The SDK module installation

The SDK module is available in GitHub repository. Download the Source code of latest release and copy d2d_analytics folder to the modules(/godot/modules/) folder of Godot engine source code.

To work in the Godot editor, compile the engine source code and the analytics module:

scons platform=macos arch=x86_64
scons platform=macos arch=arm64
lipo -create bin/godot.macos.editor.x86_64 bin/godot.macos.editor.arm64 -output bin/godot.macos.editor.universal

cp -r misc/dist/macos_tools.app ./Godot.app
mkdir -p Godot.app/Contents/MacOS
cp bin/godot.macos.editor.universal Godot.app/Contents/MacOS/Godot
cp modules/d2d_analytics/native/macos/libDTDAnalytics.dylib Godot.app/Contents/MacOS/
chmod +x Godot.app/Contents/MacOS/Godot
codesign --force --timestamp --options=runtime --entitlements misc/dist/macos/editor.entitlements -s - Godot.app

Find out more about compiling for MacOS

SDK Initialization

For initialization, add the following code at the start of your application:

var config = GDDTDAnalyticsConfiguration.new()
config.logLevel = GDDTDLogLevel.Debug
DTDAnalytics.InitializeWithConfig("AppID", config)

You can find the AppID in the settings of the respective app in devtodev (Settings → SDK → Integration → Credentials).

config - an object instance of GDDTDAnalyticsConfiguration, which is used for specifying additional properties during the initialization

Parameter

Type

Description

CurrentLevel

Integer

The player level at the moment of devtodev SDK initialization. It’s optional but we recommend using it for improving data accuracy.

UserId

String

A custom user ID assigned by the developer. In the case of default calculation by device IDs, the identifier can be used for searching users in devtodev. In case the project uses calculation by user IDs, the parameter is mandatory because it becomes the principal calculation ID in devtodev.

TrackingAvailability

GDDTDTrackingStatus (enum)

The property allows or disallows devtodev tracking of the user. By default, it is set to GDDTDTrackingStatus.Enable. SDK stores the previously assigned value. Pass GDDTDTrackingStatus.Disable if the user opted out of tracking in line with GDPR.

LogLevel

GDDTDLogLevel (enum)

The level of logging the SDK activity. The GDDTDLogLevel.No value is used by default. For troubleshooting during integration it is recommended to set it to GDDTDLogLevel.Debug, and either switch it off GDDTDLogLevel.No. Use GDDTDLogLevel.No in the release version.

Example:

var config = GDDTDAnalyticsConfiguration.new() 
config.logLevel = GDDTDLogLevel.No 
config.trackingStatus = GDDTDTrackingStatus.Enable 
config.currentLevel = 1 
config.userId = "unique_userId" 
DTDAnalytics.InitializeWithConfig("AppID", config)

Project export

Export for MacOS

Open the Export Template Manager to download and install templates:

Open a terminal, go to the root directory of the engine source code. Compile a custom template for MacOS (see Building export templates for MacOS), select Debug or Release build and processor architecture. To support both architectures in a single Universal 2 binary, use lipo:

scons platform=macos target=template_debug arch=x86_64
scons platform=macos target=template_debug arch=arm64
lipo -create bin/godot.macos.template_debug.x86_64 bin/godot.macos.template_debug.arm64 -output bin/godot.macos.template_debug.universal

The next step is to prepare a custom template as a macos.zip archive. Don't forget to add the DTDAnalytics native library, copy libDTDAnalytics.dylib to macos_template.app/Contents/MacOS/.

cp -r misc/dist/macos_template.app .
mkdir -p macos_template.app/Contents/MacOS
cp bin/godot.macos.template_debug.universal macos_template.app/Contents/MacOS/godot_macos_debug.universal
cp modules/d2d_analytics/native/macos/libDTDAnalytics.dylib macos_template.app/Contents/MacOS/
chmod +x macos_template.app/Contents/MacOS/godot_*
chmod +x macos_template.app/Contents/MacOS/libDTDAnalytics.dylib
zip -q -9 -r macos.zip macos_template.app

Open the Export menu and specify the path to the prepared custom template:

Export for iOS

Open the Export Template Manager to download and install templates:

Open a terminal, go to the root directory of the engine source code. And compile a custom template for iOS (see Compiling for iOS). To work with the iOS simulator, compile the sources with the ios_simulator=yes flag. To support both architectures in a single Universal 2 binary, use lipo:

scons p=ios target=template_debug
scons p=ios target=template_release
scons p=ios target=template_debug ios_simulator=yes arch=x86_64
scons p=ios target=template_debug ios_simulator=yes arch=arm64

cp -r misc/dist/ios_xcode .
cp bin/libgodot.ios.template_debug.arm64.a ios_xcode/libgodot.ios.debug.xcframework/ios-arm64/libgodot.a
lipo -create bin/libgodot.ios.template_debug.arm64.simulator.a bin/libgodot.ios.template_debug.x86_64.simulator.a -output ios_xcode/libgodot.ios.debug.xcframework/ios-arm64_x86_64-simulator/libgodot.a

cp bin/libgodot.ios.template_release.arm64.a ios_xcode/libgodot.ios.release.xcframework/ios-arm64/libgodot.a
lipo -create bin/libgodot.ios.template_debug.arm64.simulator.a bin/libgodot.ios.template_debug.x86_64.simulator.a -output ios_xcode/libgodot.ios.release.xcframework/ios-arm64_x86_64-simulator/libgodot.a

The next step is to prepare a custom template as an ios.zip archive. Don't forget to add the DTDAnalytics native library, copy DTDAnalytics.xcframework to ios_xcode/.

cp -r modules/d2d_analytics/native/ios/DTDAnalytics.xcframework ios_xcode/
cd "ios_xcode"
zip -q -r ios.zip ./*
cd ..
cp "ios_xcode/ios.zip" ./

In XCode project:

  1. Add DTDAnalytics.xcframework to the project (with Do Not Embed specified)

  2. Create Bridging-Header. To do this, add any swift file to the project (don't delete it later) and select 'Create Bridging Header' in the dialogue box that appears.

  3. Add frameworks:

    • AppTrackingTransparency.framework

    • AdSupport.framework

Export for Android

Сlick to install android templates:

After installing the template, an android folder will appear in your project.

Move the d2d_analytics/native/androidAnalytics.aar to the android/plugins/ folder in your project. You will also need to create an Analytics.gdap file in android/plugins/ with the following content:

[config]

name="Analytics"
binary_type="local"
binary="Analytics.aar"

[dependencies]

remote=[
    "com.google.code.gson:gson:2.8.9", 
    "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2", 
    "com.google.android.gms:play-services-ads-identifier:18.0.1",
    "com.devtodev:android-google:1.0.0"
    // Optional (recommended)
    "com.android.installreferrer:installreferrer:2.2"
    ]

custom_maven_repos=["https://repo.maven.apache.org/maven2/"]

Next, Analytics should appear in the Plugins section, check it out:

The next step is to compile the Godot engine for Android (see Android compilation), choose debug or release build, and select the processor architecture.

// Example. For debug on arm64v8 architecture use:
scons platform=android target=template_debug arch=arm64v8
//for release:
scons platform=android target=template_release arch=arm64v8

After successful compilation execute the following commands:

// Example. For debug on arm64v8 architecture use:
scons platform=android target=template_debug arch=arm64v8
//for release:
scons platform=android target=template_release arch=arm64v8

In the next step in godot-4.0-stable/bin you will see godot-lib.template_debug.aar or

godot-lib.template_relaese.aar.

You need to copy and replace this file to the previously installed template in your project at the path:

  • appName/android/build/libs/debug - for debugging

  • appName/android/build/libs/release - for release

After these steps, you are ready to export your Android app.

Make sure that Use Gradle Build (in the Gradle Build section), Analytics (in the Plugins section) and the previously compiled Architecture (in the Architectures section) are selected.

Last updated