Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,5 @@ Thumbs.db
# Temp files
temp/
/*.zip
*.uid
rc.json
23 changes: 15 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ TMP_DIR = /tmp
# ============================================================================
# Module Configuration
# ============================================================================
APPLE_MODULES = firebase_core firebase_analytics firebase_crashlytics firebase_messaging
APPLE_MODULE_NAMES = Core Analytics Crashlytics Messaging
APPLE_MODULES = firebase_core firebase_analytics firebase_crashlytics firebase_messaging firebase_remote_config
APPLE_MODULE_NAMES = Core Analytics Crashlytics Messaging RemoteConfig

ANDROID_MODULES = firebase_core firebase_analytics firebase_crashlytics firebase_messaging
ANDROID_MODULES = firebase_core firebase_analytics firebase_crashlytics firebase_messaging firebase_remote_config

# ============================================================================
# Build Configuration
Expand Down Expand Up @@ -242,17 +242,24 @@ build-apple: setup-apple
case $$module in \
firebase_core) \
echo " - Copying frameworks from FirebaseAnalytics..." && \
cp -a $(FIREBASE_SDK_DIR)/FirebaseAnalytics/*.xcframework $(IOS_PLUGINS_DIR)/$$module/ ;; \
cp -a $(FIREBASE_SDK_DIR)/FirebaseAnalytics/*.xcframework $(IOS_PLUGINS_DIR)/$$module/ && \
echo " - Copying GoogleDataTransport from FirebaseMessaging..." && \
cp -a $(FIREBASE_SDK_DIR)/FirebaseMessaging/GoogleDataTransport.xcframework $(IOS_PLUGINS_DIR)/$$module/ ;; \
firebase_analytics) \
echo " - Copying frameworks from FirebaseAnalytics..." && \
cp -a $(FIREBASE_SDK_DIR)/FirebaseAnalytics/*.xcframework $(IOS_PLUGINS_DIR)/$$module/ ;; \
firebase_crashlytics) \
echo " - Copying frameworks from FirebaseCrashlytics..." && \
cp -a $(FIREBASE_SDK_DIR)/FirebaseCrashlytics/*.xcframework $(IOS_PLUGINS_DIR)/$$module/ ;; \
cp -a $(FIREBASE_SDK_DIR)/FirebaseCrashlytics/*.xcframework $(IOS_PLUGINS_DIR)/$$module/ && \
rm -rf $(IOS_PLUGINS_DIR)/$$module/GoogleDataTransport.xcframework ;; \
firebase_messaging) \
echo " - Copying frameworks from FirebaseMessaging..." && \
cp -a $(FIREBASE_SDK_DIR)/FirebaseMessaging/*.xcframework $(IOS_PLUGINS_DIR)/$$module/ ;; \
esac); \
echo " - Copying frameworks from FirebaseMessaging..." \
&& cp -a $(FIREBASE_SDK_DIR)/FirebaseMessaging/*.xcframework $(IOS_PLUGINS_DIR)/$$module/ \
&& rm -rf $(IOS_PLUGINS_DIR)/$$module/GoogleDataTransport.xcframework ;; \
firebase_remote_config) \
echo " - Copying frameworks from FirebaseRemoteConfig..." \
&& cp -a $(FIREBASE_SDK_DIR)/FirebaseRemoteConfig/*.xcframework $(IOS_PLUGINS_DIR)/$$module/ ;; \
esac) || exit 1; \
echo " βœ“ $$module build complete (Debug + Release)"; \
echo ""; \
done
Expand Down
109 changes: 108 additions & 1 deletion addons/godotx_firebase/export_plugin.gd
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,51 @@ class AppleExportPlugin extends EditorExportPlugin:
"default_value": "res://GoogleService-Info.plist"
})

# Enable Core
options.append({
"option": {
"name": "firebase/enable_core",
"type": TYPE_BOOL
},
"default_value": true
})

# Enable Analytics
options.append({
"option": {
"name": "firebase/enable_analytics",
"type": TYPE_BOOL
},
"default_value": false
})

# Enable Crashlytics
options.append({
"option": {
"name": "firebase/enable_crashlytics",
"type": TYPE_BOOL
},
"default_value": false
})

# Enable Messaging
options.append({
"option": {
"name": "firebase/enable_messaging",
"type": TYPE_BOOL
},
"default_value": false
})

# Enable Remote Config
options.append({
"option": {
"name": "firebase/enable_remote_config",
"type": TYPE_BOOL
},
"default_value": false
})

return options


Expand Down Expand Up @@ -171,6 +216,24 @@ class AndroidExportPlugin extends EditorExportPlugin:
"default_value": "25.0.1"
})

# Enable Remote Config
options.append({
"option": {
"name": "firebase/enable_remote_config",
"type": TYPE_BOOL
},
"default_value": false
})

# Remote Config version
options.append({
"option": {
"name": "firebase/remote_config_version",
"type": TYPE_STRING
},
"default_value": "22.0.1"
})

return options


Expand Down Expand Up @@ -201,6 +264,12 @@ class AndroidExportPlugin extends EditorExportPlugin:
dependencies.append("com.google.firebase:firebase-messaging:" + version)
print("[Firebase] Adding Messaging dependency (v%s)" % version)

# Remote Config
if get_option("firebase/enable_remote_config"):
var version = get_option("firebase/remote_config_version")
dependencies.append("com.google.firebase:firebase-config-ktx:" + version)
print("[Firebase] Adding Remote Config dependency (v%s)" % version)

return dependencies


Expand All @@ -223,6 +292,9 @@ class AndroidExportPlugin extends EditorExportPlugin:
if get_option("firebase/enable_messaging"):
modules.append("firebase_messaging")

if get_option("firebase/enable_remote_config"):
modules.append("firebase_remote_config")

# Search for AARs in each module's directory
for module in modules:
var module_path: String = "res://android/" + module + "/"
Expand Down Expand Up @@ -279,6 +351,41 @@ class AndroidExportPlugin extends EditorExportPlugin:

out_file.store_buffer(content)
out_file.close()
print("[Firebase] βœ“ Copied google-services.json β†’ " + dest_res_path)

print("[Firebase] Copied Android config to " + dest_res_path)
# Patch Gradle files to declare and apply the Crashlytics Gradle plugin.
# The plugin is required at build time to inject a build UUID into the APK.
# Without it the app crashes on launch when Crashlytics is enabled.
if get_option("firebase/enable_crashlytics"):
_patch_gradle_file(
"res://android/build/settings.gradle",
"id 'com.google.gms.google-services' version '4.4.2'",
"id 'com.google.gms.google-services' version '4.4.2'\n id 'com.google.firebase.crashlytics' version '3.0.3'",
"settings.gradle"
)
_patch_gradle_file(
"res://android/build/build.gradle",
"id 'com.google.gms.google-services'",
"id 'com.google.gms.google-services'\n id 'com.google.firebase.crashlytics'",
"build.gradle"
)


func _patch_gradle_file(res_path: String, needle: String, replacement: String, label: String) -> void:
if not FileAccess.file_exists(res_path):
push_warning("[Firebase] %s not found, skipping Crashlytics Gradle plugin injection" % label)
return
var f := FileAccess.open(res_path, FileAccess.READ)
var text := f.get_as_text()
f.close()
if "firebase.crashlytics" in text:
return
var patched := text.replace(needle, replacement)
if patched == text:
push_warning("[Firebase] Could not inject Crashlytics plugin into %s β€” pattern not found" % label)
return
var out := FileAccess.open(res_path, FileAccess.WRITE)
out.store_string(patched)
out.close()
print("[Firebase] βœ“ Injected Crashlytics Gradle plugin into %s" % label)

2 changes: 1 addition & 1 deletion android/.build_version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.5.1.stable
4.6.1.stable
Loading