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 59f0feb commit 5f57ca5
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 0 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/build-ios.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Build iOS App

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build:
runs-on: macos-latest

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

- name: Install SDL2
run: |
brew install sdl2 sdl2_image sdl2_mixer sdl2_ttf
- name: Compile the iOS App
run: |
mkdir -p build
clang -o build/MyIOSApp main.c -F/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simulator.sdk/System/Library/Frameworks -framework SDL2 -framework UIKit -framework Foundation -framework CoreGraphics
- name: Upload the build artifact
uses: actions/upload-artifact@v2
with:
name: ios-app
path: build/MyIOSApp
56 changes: 56 additions & 0 deletions main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#include <SDL2/SDL.h>
#include <stdio.h>

int main(int argc, char *argv[]) {
// Initialize SDL
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
fprintf(stderr, "Could not initialize SDL: %s\n", SDL_GetError());
return 1;
}

// Create a window
SDL_Window *window = SDL_CreateWindow("My iOS App",
SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED,
800, 600,
SDL_WINDOW_SHOWN);
if (!window) {
fprintf(stderr, "Could not create window: %s\n", SDL_GetError());
SDL_Quit();
return 1;
}

// Create a renderer
SDL_Renderer *renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
if (!renderer) {
fprintf(stderr, "Could not create renderer: %s\n", SDL_GetError());
SDL_DestroyWindow(window);
SDL_Quit();
return 1;
}

// Main loop flag
int running = 1;
SDL_Event event;

// Main loop
while (running) {
while (SDL_PollEvent(&event)) {
if (event.type == SDL_QUIT) {
running = 0;
}
}

SDL_SetRenderDrawColor(renderer, 0, 128, 255, 255); // Blue
SDL_RenderClear(renderer);
SDL_RenderPresent(renderer);
}

// Cleanup
SDL_DestroyRenderer(renderer);
SDL_DestroyWindow(window);
SDL_Quit();

return 0;
}

0 comments on commit 5f57ca5

Please sign in to comment.