An open API service indexing awesome lists of open source software.

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.

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
```