SDL2-Swift
Swift library for SDL2.
C libraries use their respective names for their module names import SDL2_TTF
. The swifty wrappers append 'Swift' onto the module name import SDL2_TTFSwift
. Not sure what's the cleanest solution tbh. As a matter of fact, it's likely that I'll refactor the swifty wrappers frequently.
This repo also serves as a minimum example project for running on windows. Note: I have yet to test SDL2_TTFSwift on windows
Note: I'm going to some refactor IndexRepresentable stuff soon. As well as see if I can add attributes to enums on the mainline SDL2 source which will result in some breaking changes.
Running on Windows
-
Follow the instructions here to install swift: https://github.com/pwsacademy/swift-setup/tree/main/platforms/windows
-
Follow the instructions here to setup vscode: https://github.com/pwsacademy/swift-setup/tree/main/editors/vscode-windows
- Optional: Create a test hello world project to make sure and hit a breakpoint to make sure everything is working
-
Run
.\downloadBinaries.ps1
Or:- Download SDL2 manually.
- Copy SDL2.dll, SDL2_ttf.dll, etc files into this folder
- Copy the appropiate files into
windows_bin\include
andwindows_bin\lib\x64
-
Run
.\fix_vscode_settings.ps1
- SourceKit needs to be pointed to the SDL directories for intellisense.
-
Open the project folder in vscode and hitting the Run and debug button should work fine.
If you wish to run manually without vscode then run:
swift build --product "SDLDemo" -c debug -Xswiftc -Iwindows_bin\\include -Xlinker -Lwindows_bin\\lib\\x64
.\.build\debug\SDLDemo.exe
We're using swift build
because swift run
can't find the SDL directories for some reason.