While investigating SDL 2.0 for an upcoming project, we found that there was not a good starting point for an SDL project in Xcode.
This repository is meant to serve as an example of a Hello World project in SDL using Xcode. You should be able to clone this repository and get going right away, provided that you have the SDL2 framework installed (see below).
The code in main.cpp
is largely based on this SDL tutorial and covers creating a window, a renderer, and displaying a bitmap.
As of the time of this writing, the SDL 2 framework available for download from the official site will not work due to a code signing error. Until then, you can build the framework yourself in Xcode. It only takes a few steps (which we got thanks to this StackOverflow answer).
- Install mercurial if you don't have it already.
- From the terminal, run
hg clone http://hg.libsdl.org/SDL
to clone the SDL source. - Open
XCode/SDL/SDL.xcodeproj
in Xcode. - Compile the framework.
- In the left-hand navigation pane, open
Products
, right-clickSDL2.framework
, and selectShow in finder
. - Copy this file (
SDL2.framework
) to/Library/Frameworks
.
After all that, you should be able to compile this project with no problem. If it succeeded, you should see a Hello world
image in a 640x480 window for about 5 seconds.
© 2014 Float. Shared under an MIT license. See license.md for details.