-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add GitHub Actions workflow for iOS build
- Loading branch information
1 parent
59f0feb
commit 5f57ca5
Showing
2 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
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 |
This file contains 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
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; | ||
} | ||
|