feat: add Android OTG keyboard support, browser arrow-key navigation,… #213
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: iOS Build | |
| on: | |
| push: | |
| branches: [ "main", "master" ] | |
| pull_request: | |
| branches: [ "main", "master" ] | |
| jobs: | |
| build: | |
| runs-on: macos-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Zig | |
| uses: mlugg/setup-zig@v1 | |
| with: | |
| version: 0.11.0 | |
| - name: Checkout Raylib | |
| run: | | |
| git clone https://github.com/raysan5/raylib.git raylib-src | |
| cd raylib-src && git checkout 5.0 | |
| - name: Build Raylib for iOS (arm64) | |
| run: | | |
| SDK_PATH=$(xcrun --sdk iphoneos --show-sdk-path) | |
| cd raylib-src/src | |
| # Fix include paths for iOS native GLES2 (Apple uses OpenGLES/ES2/ instead of GLES2/) | |
| find . \( -name "*.h" -o -name "*.c" \) | xargs sed -i '' \ | |
| -e 's|<GLES2/gl2\.h>|<OpenGLES/ES2/gl.h>|g' \ | |
| -e 's|<GLES2/gl2ext\.h>|<OpenGLES/ES2/glext.h>|g' | |
| # Common iOS clang flags | |
| IOS_FLAGS="-target arm64-apple-ios14.0 -isysroot $SDK_PATH \ | |
| -DPLATFORM_IOS -DGRAPHICS_API_OPENGL_ES2 \ | |
| -DGLES_SILENCE_DEPRECATION -DGL_GLEXT_PROTOTYPES \ | |
| -Wno-implicit-function-declaration -Wno-macro-redefined \ | |
| -I. -O2" | |
| # Inject missing GLES extension typedefs and defines for iOS. | |
| printf '%s\n' \ | |
| '#ifndef GLES_FIX_H' \ | |
| '#define GLES_FIX_H' \ | |
| '#include <OpenGLES/ES2/gl.h>' \ | |
| '#include <OpenGLES/ES2/glext.h>' \ | |
| 'typedef void (*PFNGLGENVERTEXARRAYSOESPROC)(GLsizei n, GLuint *arrays);' \ | |
| 'typedef void (*PFNGLBINDVERTEXARRAYOESPROC)(GLuint array);' \ | |
| 'typedef void (*PFNGLDELETEVERTEXARRAYSOESPROC)(GLsizei n, const GLuint *arrays);' \ | |
| 'typedef void (*PFNGLDRAWARRAYSINSTANCEDEXTPROC)(GLenum mode, GLint first, GLsizei count, GLsizei primcount);' \ | |
| 'typedef void (*PFNGLDRAWELEMENTSINSTANCEDEXTPROC)(GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount);' \ | |
| 'typedef void (*PFNGLVERTEXATTRIBDIVISOREXTPROC)(GLuint index, GLuint divisor);' \ | |
| '#define GL_DEPTH_COMPONENT32_OES 0x81A7' \ | |
| '#define GL_DEPTH_COMPONENT24_OES 0x81A6' \ | |
| '#define GL_RED_EXT 0x1903' \ | |
| '#define GL_R32F_EXT 0x822E' \ | |
| '#define GL_RGB32F_EXT 0x8815' \ | |
| '#define GL_RGBA32F_EXT 0x8814' \ | |
| '#define GL_R16F_EXT 0x822D' \ | |
| '#define GL_RGB16F_EXT 0x881B' \ | |
| '#define GL_RGBA16F_EXT 0x881A' \ | |
| '#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7' \ | |
| '#endif' \ | |
| > gles_fix.h | |
| echo "=== gles_fix.h written ===" | |
| cat gles_fix.h | |
| # Prepend #include "gles_fix.h" at line 1 of rlgl.h | |
| sed -i '' '1s|^|#include "gles_fix.h"\n|' rlgl.h | |
| # Common iOS clang flags (no -x flag here ΓÇö set per-file below) | |
| IOS_FLAGS="-target arm64-apple-ios14.0 -isysroot $SDK_PATH \ | |
| -DPLATFORM_IOS -DGRAPHICS_API_OPENGL_ES2 \ | |
| -DGLES_SILENCE_DEPRECATION -DGL_GLEXT_PROTOTYPES \ | |
| -Wno-implicit-function-declaration -Wno-macro-redefined \ | |
| -I. -O2" | |
| # Compile each raylib source file as plain C (no -x override needed) | |
| # NOTE: raudio.c is EXCLUDED to avoid duplicate miniaudio symbols with the app's audio backend. | |
| for src in rcore.c rshapes.c rtextures.c rtext.c utils.c rmodels.c; do | |
| echo "=== Compiling $src ===" | |
| clang -x c $IOS_FLAGS -c $src -o ${src%.c}.o | |
| done | |
| # Pack all object files into a static library | |
| ar rcs libraylib.a rcore.o rshapes.o rtextures.o rtext.o utils.o rmodels.o | |
| echo "=== libraylib.a built successfully ===" | |
| ls -lh libraylib.a | |
| mkdir -p ../../platform/ios/libs | |
| cp libraylib.a ../../platform/ios/libs/ | |
| - name: Bundle Assets | |
| run: | | |
| gcc tools/bin2c.c -o tools/bin2c | |
| gcc tools/gen_splash_bundle.c -o tools/gen_splash_bundle | |
| rm -f src/ui/components/assets_bundle.h | |
| echo "#ifndef ASSETS_BUNDLE_H" > src/ui/components/assets_bundle.h | |
| echo "#define ASSETS_BUNDLE_H" >> src/ui/components/assets_bundle.h | |
| ./tools/bin2c "assets/fonts/otfs/Font Awesome 5 Free-Solid-900.otf" src/ui/components/assets_bundle.h font_awesome_solid append | |
| ./tools/bin2c "assets/fonts/otfs/Font Awesome 5 Free-Regular-400.otf" src/ui/components/assets_bundle.h font_awesome_regular append | |
| ./tools/bin2c "assets/fonts/otfs/Font Awesome 5 Brands-Regular-400.otf" src/ui/components/assets_bundle.h font_awesome_brand append | |
| ./tools/bin2c "assets/splash.png" src/ui/components/assets_bundle.h unx_logo append | |
| ./tools/bin2c "assets/icons/crown.png" src/ui/components/assets_bundle.h icon_crown append | |
| ./tools/bin2c "assets/icons/star.png" src/ui/components/assets_bundle.h icon_star append | |
| ./tools/gen_splash_bundle assets/splash src/ui/components/splash_bundle_tmp.h | |
| cat src/ui/components/splash_bundle_tmp.h >> src/ui/components/assets_bundle.h | |
| echo "#endif" >> src/ui/components/assets_bundle.h | |
| - name: Compile XDJ-UNX for iOS | |
| run: | | |
| SDK_PATH=$(xcrun --sdk iphoneos --show-sdk-path) | |
| mkdir -p build/ios/obj | |
| IOS_BASE="-target arm64-apple-ios14.0 -isysroot $SDK_PATH \ | |
| -Isrc -Isrc/core -Isrc/engine -Ilib -Iraylib-src/src \ | |
| -Ilib/qm-dsp -Ilib/soundtouch -Ilib/fidlib \ | |
| -O2 -DPLATFORM_IOS -DKS_STR_ENCODING_NONE -Dkiss_fft_scalar=double -DT_LINUX \ | |
| -DGLES_SILENCE_DEPRECATION" | |
| # --- audio_backend.c: compile as Objective-C --- | |
| # This file defines MINIAUDIO_IMPLEMENTATION which causes miniaudio.h | |
| # to include AVFoundation ΓÇö same issue as raylib's raudio.c. | |
| # -x objective-c MUST come before the filename. | |
| echo "Compiling (ObjC) src/core/audio_backend.c" | |
| clang -x objective-c $IOS_BASE \ | |
| -c src/core/audio_backend.c \ | |
| -o build/ios/obj/src_core_audio_backend.c.o | |
| # --- Compile remaining .c files as plain C --- | |
| # Include src and lib, but exclude: | |
| # - Windows-only midi backend | |
| # - audio_backend.c (handled as ObjC) | |
| # - raylib's linux-specific lib folder | |
| # - qm-dsp hmm/segmentation (unused and missing deps) | |
| # - any tests/test folders | |
| C_FILES=$(find src lib -name "*.c" \ | |
| | grep -v "midi_backend_win.c" \ | |
| | grep -v "system_windows.c" \ | |
| | grep -v "src/core/audio_backend.c" \ | |
| | grep -v "lib/linux_arm64" \ | |
| | grep -v "lib/qm-dsp/hmm" \ | |
| | grep -v "lib/qm-dsp/dsp/segmentation" \ | |
| | grep -v "/tests/" \ | |
| | grep -v "/test/") | |
| for f in $C_FILES; do | |
| obj="build/ios/obj/$(echo $f | tr '/' '_').o" | |
| echo "Compiling (C) $f -> $obj" | |
| clang -x c $IOS_BASE -c "$f" -o "$obj" | |
| done | |
| # --- Compile .cpp and .cc files as C++ --- | |
| # Exclude: linux platform, tests, and qm-dsp hmm/segmentation | |
| CPP_FILES=$(find src lib -name "*.cpp" -o -name "*.cc" 2>/dev/null \ | |
| | grep -v "lib/linux_arm64" \ | |
| | grep -v "/tests/" \ | |
| | grep -v "/test/" \ | |
| | grep -v "lib/qm-dsp/hmm" \ | |
| | grep -v "lib/qm-dsp/dsp/segmentation" || true) | |
| for f in $CPP_FILES; do | |
| obj="build/ios/obj/$(echo $f | tr '/' '_').o" | |
| echo "Compiling (C++) $f -> $obj" | |
| clang++ $IOS_BASE -std=c++17 -Ilib/kaitai -Ilib/rekordbox-metadata \ | |
| -c "$f" -o "$obj" | |
| done | |
| # --- Compile Objective-C .m files (platform/ios entry points) --- | |
| M_FILES=$(find src platform/ios -name "*.m" 2>/dev/null || true) | |
| for f in $M_FILES; do | |
| obj="build/ios/obj/$(echo $f | tr '/' '_').o" | |
| echo "Compiling (ObjC) $f -> $obj" | |
| clang -x objective-c $IOS_BASE -fobjc-arc -c "$f" -o "$obj" | |
| done | |
| # --- Link --- | |
| clang++ -target arm64-apple-ios14.0 -isysroot $SDK_PATH \ | |
| build/ios/obj/*.o \ | |
| -Wl,-force_load,platform/ios/libs/libraylib.a \ | |
| -framework UIKit \ | |
| -framework QuartzCore \ | |
| -framework CoreGraphics \ | |
| -framework CoreAudio \ | |
| -framework AudioToolbox \ | |
| -framework AVFoundation \ | |
| -framework Foundation \ | |
| -framework CoreFoundation \ | |
| -framework OpenGLES \ | |
| -framework CoreVideo \ | |
| -framework CoreText \ | |
| -framework CoreMedia \ | |
| -stdlib=libc++ \ | |
| -o build/ios/xdjunx | |
| # Fake-sign for TrollStore / jailbreak sideloading | |
| codesign -s - --force --entitlements platform/ios/Entitlements.plist build/ios/xdjunx | |
| - name: Package IPA | |
| run: | | |
| mkdir -p Payload/xdjunx.app | |
| cp build/ios/xdjunx Payload/xdjunx.app/ | |
| cp platform/ios/Info.plist Payload/xdjunx.app/ | |
| mkdir -p Payload/xdjunx.app/assets | |
| cp -r assets/* Payload/xdjunx.app/assets/ | |
| mkdir -p Payload/xdjunx.app/assets/controllers | |
| cp -r controllers/* Payload/xdjunx.app/assets/controllers/ | |
| # Copy App Icons | |
| cp platform/ios/Assets.xcassets/AppIcon.appiconset/*.png Payload/xdjunx.app/ | |
| zip -r xdjunx-unsigned.ipa Payload | |
| - name: Upload Artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: UNX-ENGINE-iOS-Unsigned | |
| path: xdjunx-unsigned.ipa |