SwiftGodot Apple Sign-In Library โจ
March 18, 2025 ยท View on GitHub
A lightweight, easy-to-integrate library for implementing Apple Sign-In with Godot 4.3+ on iOS
๐ Project Structure
Bin/
ios/
MyLibrary.framework/
Info.plist
MyLibrary
SwiftGodot.framework/
Info.plist
SwiftGodot
๐ ๏ธ Building the Framework ( i already have built it for you Bin/ios/ if you don't see it continue below )
To build the framework, run the following commands:
chmod +x build.sh
./build.sh ios release
After running the script, you will find the built files inside the Bin/ directory.
๐ Setting Up in Godot
- Create a new file named
MyLibrary.gdextensionin the root directory (res://). - Paste the following content into the file:
[configuration]
entry_symbol = "swift_entry_point"
compatibility_minimum = "4.3"
[libraries]
ios.release = "res://Bin/ios/MyLibrary.framework"
[dependencies]
ios.release = {"res://Bin/ios/SwiftGodot.framework" : ""}
๐ Important:
- This file is required to link Godot to iOS.
- Copy the framework files into
res://Bin/ios/before running Godot.
๐ฅ Godot Script Example
Here's a sample Godot script (GDScript) demonstrating how to use Apple Sign-In:
extends Control
@onready var apple_button = $Panel/AppleLoginButton
@onready var error_label = $Panel/MarginContainer/ErrorLabel
# Variable for MyLibrary
var my_library = null
# Plugin configuration for Apple Sign-In
const APPLE_PLUGIN_NAME := "MyLibrary" # Matches your Swift extension name
func _ready() -> void:
initialize_plugins()
apple_button.pressed.connect(_on_apple_button_pressed)
func initialize_plugins() -> void:
if my_library == null && ClassDB.class_exists(APPLE_PLUGIN_NAME):
my_library = ClassDB.instantiate(APPLE_PLUGIN_NAME)
# Connect to signals defined in MyLibrary.swift
my_library.connect("Output", _on_apple_output_signal)
my_library.connect("Signout", _on_apple_signout_signal)
print("MyLibrary initialized via ClassDB")
else:
push_error("Apple Sign-In extension not found: %s" % APPLE_PLUGIN_NAME)
error_label.show()
error_label.text = "Apple Sign-In unavailable"
func _on_apple_button_pressed() -> void:
if my_library:
if my_library.has_method("signIn"):
my_library.signIn()
else:
error_label.show()
push_error("Apple plugin not initialized")
error_label.text = "Apple Sign-In error"
func _on_apple_output_signal(output: String) -> void:
# Handle the Output signal from MyLibrary
error_label.show()
error_label.text = output
func _on_apple_signout_signal(signout: String) -> void:
# Handle the Signout signal from MyLibrary
error_label.show()
error_label.text = signout
๐ Rebuilding & Updating the Plugin
If you modify the Swift code, follow these steps to rebuild and update:
chmod +x build.sh
./build.sh ios release
Then, copy the updated files from Bin/ to your Godot project and repeat the setup process.
๐ Features
- Easy integration with Godot 4.3+
- Seamless Apple Sign-In implementation
- Simple signals for handling authentication results
- Lightweight and optimized for iOS
๐ Acknowledgements
๐ฎ Try My Games!
See this plugin in action and support my work!
|
Ludo World War |
Ludo World War
|
โญ Your ratings & reviews help tremendously! โญ
Help us grow and bring you more amazing features!
Enjoy coding & gaming! ๐ฎ๐