Code Monkey home page Code Monkey logo

gdnative_ios's Introduction

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=<target> -j4  
scons platform=ios ios_arch=arm64 target=<target> -j4  

scons platform=ios ios_arch=arm64 ios_simulator=yes target=<target> -j4  
scons platform=ios ios_arch=x86_64 ios_simulator=yes target=<target> -j4  

lipo -create bin/libgodot-cpp.ios.<target>.arm64.a bin/libgodot-cpp.ios.<target>.armv7.a -output bin/gdnative.fat.device.a
lipo -create bin/libgodot-cpp.ios.<target>.x86_64.simulator.a bin/libgodot-cpp.ios.<target>.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

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=<arch> target_name=<library_name> gdnative_lib_path=<optional path to gdnative libraries> gdnative_lib=<optional library name>

Building Dynamic library

To build .dylib library run:

scons platform=ios arch=<arch> target_name=<library_name> mode=dynamic gdnative_lib_path=<optional path to gdnative libraries> gdnative_lib=<optional library name>

Building XCFramework

Requirements

To create a .xcframework from .a library run:

xcodebuild -create-xcframework \
    -library <library_1> \
    ...
    -library <library_2> \
    -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_1> \
    ...
    -framework <framework_2> \
    -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 <project_name> <scheme_name> <product_name>

Example:

bash ./xcframework_build.sh gdnative_ios.xcodeproj library gdexample

gdnative_ios's People

Contributors

naithar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.