SFML 2 Mac OS X Development
How to install and get SFML development working on Mac OS X. This version uses an OS X Mavericks operating system and the SFML 2.1 installation guide: "SFML and Xcode (Mac OS X"
Set Up Xcode 5
- Ensure your OS is up to date.
- Install Xcode 5 from the app store. Xcode will come bundled with the Command Line Tools necessary to compile SFML applications.
- Create a project folder to store the SFML Distribution files, your source code and any published app.
- Download the Clang Universal SFML packages located here ("Download SFML 2.1") to your project directory.
- Unarchive the download which should unpack into like: SFML-2.1-osz-clang-universal/
- Copy the contents of the unpacked Frameworks/ directory to /Library/Frameworks/
- Copy the SFML dependencies sndfile.framework and freetype.framework from extlibs/ to /Library/Frameworks/
- Download the Xcode 5 Templates located here ("Download SFML 2.1") to your project directory.
- Unarchive the download which should unpack into something like: xcode/templates/
- Open a terminal and run the install script located within xcode/templates/ or copy the SFML folder to /Library/Developer/Xcode/Templates/
Create Xcode Project
- Open Xcode.
- Create the SFML App through File > New > Project.
- Select SFML under OS X and choose the "SFML App" template.
- Fill out the application options area as shown:
- Click "Next" and choose the project folder create before. The project will now be setup and ready to run as a standalone .app
- The template will generate a main.cpp file and starting resources, and an OS X resource path function.
- ResourcePath.hpp and ResourcePath.mm are OS X specific functionality
- ResourcePath.mm has Objective C++ code Xcode will compile
- You must re-implement the resourcePath() function on each operating system to access the content folder you store resources in.
- Your project folder will look like:
- source files and resources...
- Click on the project in Xcode > Build Phases > Link Binary With Libraries and add OpenGL.Framework if you intend to do any custom Open GL coding.
Running and Publishing
- Run your project to verify that it works.
- To publish the .app go to Product > Archive > Distribute > Export As > Application
Adding Source to Xcode
Groups are required for the linker to work. Folders don't work. Its easiest to delete all the old source groups from the project and drag from Finder them back in, choosing to make groups.