Setting Up SDL2 using XCode 6 in OSX

My first semester in DigiPen has just ended and I get to make tutorials again! One of my classes was Game Engine Fundamentals and I used SDL2 to create my game engine. SDL2 is a cross-platform C library to create games on. My favorite tutorial to learn SDL is Lazy Foo. He gives a detailed tutorial in multiple aspects of the library. However, setting up on Mac is not yet done. Hence, I have created this post.

First and foremost, I used MacPorts to download the SDL2 library. It’s similar to apt-get or yum in linux.

If you’re using the SDL2 Frameworks for OSX from the LibSDL site, the process is similar except for the location of the headers, which are inside the framework itself.

Header Location for SDL2.Framework

Header Location inside SDL2.Framework

Note that each Framework (SDL2_image, SDL2_net, SDL2_ttf, SDL2_mixer) contains its own header files.

Also, there’s a code signature mismatch with the SDL2.Framework preventing you from running an archived (release) version of your project. According to this, you need to codesign like so:

My suggestion: use MacPorts. All SDL2 headers will be in the same location (/opt/local/include/SDL2/) and you link with a ready-made dynamic library (no codesign needed).

One thought on “Setting Up SDL2 using XCode 6 in OSX

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.