Skip to content

Commit

Permalink
Add GitHub Actions workflow for iOS build
Browse files Browse the repository at this point in the history
  • Loading branch information
vrstanchev committed Nov 4, 2024
1 parent 1acad0b commit db71a8b
Showing 1 changed file with 57 additions and 28 deletions.
85 changes: 57 additions & 28 deletions .github/workflows/build-ios.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build iOS App
name: Build Android App with SDL2

on:
push:
Expand All @@ -10,51 +10,80 @@ on:

jobs:
build:
runs-on: macos-latest
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Install dependencies
- name: Install required packages
run: |
brew update
brew install cmake # Assuming you might need CMake for SDL2 build
sudo apt update
sudo apt install -y build-essential git wget unzip
- name: Clone SDL2 repository
- name: Install Android SDK and NDK
run: |
mkdir -p $HOME/android-sdk $HOME/android-ndk
wget https://dl.google.com/android/repository/commandlinetools-linux-6609375_latest.zip
unzip commandlinetools-linux-6609375_latest.zip -d $HOME/android-sdk
rm commandlinetools-linux-6609375_latest.zip
echo "export ANDROID_HOME=$HOME/android-sdk" >> $GITHUB_ENV
echo "export PATH=$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/platform-tools:$PATH" >> $GITHUB_ENV
yes | sdkmanager --sdk_root=$HOME/android-sdk "platforms;android-26" "ndk;21.4.7075529" "platform-tools" "build-tools;30.0.3"
- name: Accept licenses
run: yes | sdkmanager --licenses

- name: Clone SDL2 for Android
run: |
git clone https://github.com/libsdl-org/SDL.git
cd SDL
git checkout main # or the desired branch/tag
echo "SDL2 repository cloned."
git checkout main # Or specify the desired branch/tag
- name: Build SDL2 for iOS
- name: Build SDL2 for Android
run: |
cd SDL/Xcode-iOS
cd SDL/android
./build-sdl.sh
echo "SDL2 built for iOS."
- name: Verify SDL2 Installation Path
run: |
echo "SDL2 path:" $(pwd)/Xcode-iOS/build/ios/Debug-iphoneos/
ls Xcode-iOS/build/ios/Debug-iphoneos/include/SDL2
echo "SDL2 built for Android."
- name: Compile the iOS App
- name: Compile the Android app
run: |
mkdir -p build
SDK_PATH=$(xcrun --sdk iphoneos --show-sdk-path)
clang -v -o build/MyIOSApp main.c \
-I$(pwd)/SDL/Xcode-iOS/build/ios/Debug-iphoneos/include \
-L$(pwd)/SDL/Xcode-iOS/build/ios/Debug-iphoneos/lib \
cd build
$ANDROID_HOME/ndk/21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/bin/clang \
-o MyApp.so \
-I$HOME/android-sdk/ndk/21.4.7075529/sources/android/native_app_glue \
-I$HOME/android-sdk/ndk/21.4.7075529/sources/SDL2 \
../main.c \
-lSDL2 \
-framework UIKit \
-framework Foundation \
-framework CoreGraphics \
-isysroot $SDK_PATH \
-arch arm64
-target aarch64-linux-android21 \
-fPIC
- name: Build APK
run: |
cd build
echo "Creating Android APK..."
cat <<EOF > Android.mk
LOCAL_PATH := \$(call my-dir)
include \$(CLEAR_VARS)
LOCAL_MODULE := MyApp
LOCAL_SRC_FILES := MyApp.so
include \$(BUILD_SHARED_LIBRARY)
EOF
echo "Creating Application.mk..."
cat <<EOF > Application.mk
APP_ABI := arm64-v8a
APP_PLATFORM := android-26
EOF
cd $HOME/android-sdk/ndk/21.4.7075529/build/outputs/apk
ndk-build NDK_PROJECT_PATH=$HOME/android-sdk/ndk/21.4.7075529/build \
APP_BUILD_SCRIPT=Android.mk \
NDK_APPLICATION_MK=Application.mk
- name: Upload the build artifact
uses: actions/upload-artifact@v3
with:
name: ios-app
path: build/MyIOSApp
name: android-app
path: $HOME/android-sdk/ndk/21.4.7075529/build/outputs/apk/*.apk

0 comments on commit db71a8b

Please sign in to comment.