https://github.com/naithar/gdnative_ios
Starter project for building GDNative modules for iOS platform.
https://github.com/naithar/gdnative_ios
gdnative godot godotengine ios
Last synced: about 1 year ago
JSON representation
Starter project for building GDNative modules for iOS platform.
- Host: GitHub
- URL: https://github.com/naithar/gdnative_ios
- Owner: naithar
- Created: 2020-06-30T17:11:49.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2021-02-09T06:33:02.000Z (over 5 years ago)
- Last Synced: 2025-04-01T05:41:25.684Z (about 1 year ago)
- Topics: gdnative, godot, godotengine, ios
- Language: Python
- Homepage:
- Size: 24.4 KB
- Stars: 6
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# iOS example for GDNative
This repo contains a *starter* XCode project and SCons configuration to build GDNative library for iOS platform.
XCode project allows to build **.framework** or **.xcframework** (using specific script).
SCons configuration builds a static (**.a**) or dynamic (**.dylib**) iOS library.
All resulting products can be used for creating GDNative library in Godot project.
# Initial Setup
## Compiling GDNative
To generate **libgdnative.fat.a** perform inside **godot-cpp** directory:
```
scons platform=ios ios_arch=armv7 target= -j4
scons platform=ios ios_arch=arm64 target= -j4
scons platform=ios ios_arch=arm64 ios_simulator=yes target= -j4
scons platform=ios ios_arch=x86_64 ios_simulator=yes target= -j4
lipo -create bin/libgodot-cpp.ios..arm64.a bin/libgodot-cpp.ios..armv7.a -output bin/gdnative.fat.device.a
lipo -create bin/libgodot-cpp.ios..x86_64.simulator.a bin/libgodot-cpp.ios..arm64.simulator.a -output bin/gdnative.fat.simulator.a
```
For more detailed information about building **gdnative** binary and using resulting dynamic or static library go to [Godot Docs](https://docs.godotengine.org/en/stable/tutorials/plugins/gdnative/gdnative-cpp-example.html)
# Working with XCode
Change **Bundle Identifier** to some unique value. Each framework should have different bundle identifiers.
Change **Product Name** parameter in **Build Settings** tab to the name you would want to use.
Add source files to project.
# Building Static library
## Requirements
Using static (**.a**) library will require adding and linking **libgdnative.fat.a** that was previously built to exported iOS app. This can be simplified by moving **libgdnative.fat.a** to godot project folder and adding it as dependency in **.gdnlib** file.
To build **.a** library run:
```
scons platform=ios arch= target_name= gdnative_lib_path= gdnative_lib=
```
# Building Dynamic library
To build **.dylib** library run:
```
scons platform=ios arch= target_name= mode=dynamic gdnative_lib_path= gdnative_lib=
```
# Building XCFramework
## Requirements
To create a **.xcframework** from `.a` library run:
```
xcodebuild -create-xcframework \
-library \
...
-library \
-output "./bin/$1.$2.xcframework"
```
To create a **.xcframework** from `.dylib` library you will have to create `.framework` from `.dylib` and then run:
```
xcodebuild -create-xcframework \
-framework \
...
-framework \
-output "./bin/$1.$2.xcframework"
```
Alternatively you can use `xcframework_build.sh` script, but it might require tweaks in Xcode project.
```
bash ./xcframework_build.sh
```
Example:
```
bash ./xcframework_build.sh gdnative_ios.xcodeproj library gdexample
```