Mac Development Guide
This page provides background and instructions to setup the Xcode development environment in order to compile FreeSpace 2 Open SCP. After following these instructions you will have a working Xcode build environment, a checked out copy of the latest FS2_Open source code, and compiled binaries of the latest revision of the FS2_Open engine.
Contents
Getting Xcode
Xcode is the integrated development environment (IDE) that Apple provides free of charge for the Mac OS platform. It is the Mac equivalent to Microsoft Visual Studio. In practice, Xcode provides a graphical interface to an underlying Clang/LLVM compiler; with the addition of platform libraries (Frameworks), code completion, project management and the other features you would expect of a modern IDE.
Xcode is available free from the Mac App Store.
It is strongly recommended that you update to the latest version of Xcode compatible with your Mac OS version, as prior versions have bugs which prevent FS2_Open from compiling properly.
OS X 10.9 | OS X 10.8.5 | OS X 10.7 | OS X 10.6.8 | |
---|---|---|---|---|
Xcode 5.0.2 | Yes | Yes | n/a | n/a |
Xcode 4.2.1 | n/a | n/a | Partially | Not as yet |
Xcode 3.2.6 | n/a | n/a | Yes | Yes |
Xcode 3.1.4 | n/a | n/a | n/a | No |
Xcode 3.0.0 | n/a | n/a | n/a | Unknown |
Getting FreeSpace 2 Open SCP source code
Open Terminal.app through Spotlight, or it can be found in /Applications/Utilities/Terminal.app. This is the console command line for Mac OS. You will need a location to save the checked out source code. The following commands will create a new folder in your personal Documents called 'coding' and then within a subfolder specific for FS2_Open called 'fs2_open' checkout the latest Subversion revision.
cd Documents mkdir coding cd coding svn checkout svn://svn.icculus.org/fs2open/trunk/fs2_open fs2_open
Open Finder and browse to ~/Documents/coding/fs2_open/ to see the new files that have been downloaded from the FS2_Open Subversion source code repository.
FS2_Open currently uses some precompiled third party Frameworks to handle music and video on Mac OS, which are stored in compressed form within Subversion. Open the 'projects' folder and then 'Xcode4'. This is the location of recent Xcode specific project files and settings. For now, double click on Frameworks.tgz to uncompress these Frameworks to a new folder called Frameworks.
Your local SVN checkout of the FreeSpace 2 Open SCP code can be keep up to date with the latest changes by opening Terminal.app again, and running the following commands
cd Documents/coding/fs2_open svn up
Xcode and the FreeSpace 2 Open SCP source code is now setup, so let's start our first compilation by double clicking on the FS2_Open.xcodeproj Xcode project file.
Compiling FreeSpace 2 Open SCP source code (GUI)
Click the 'Build' button or press Apple key+B. This should complete successfully, and once done the binary application can be found within 'projects/Xcode4/build/'. Open the folder with the same name as the build type you selected previously to find the compiled FS2_Open application.
Compiling FreeSpace 2 Open SCP source code (Command line)
Open Terminal.app and run the following commands to build a Debug version of FS2_Open
cd Documents/coding/fs2_open/projects/Xcode4 xcodebuild
In order to build an AddressSanitizer build, first a trunk version of Clang/LLVM must be downloaded and installed as the Apple-supplied Clang does not enable AddressSanitizer features.
Following the instructions at http://clang.llvm.org/get_started.html
Then use this trunk build of Clang instead of the Apple-supplied Clang to build FS2_Open with AddressSanitizer
cd Documents/coding/fs2_open/projects/Xcode4 export CC=/path/to/llvm/../build/[Release+Assert]/bin/clang export CXX=/path/to/llvm/../build/[Release+Assert]/bin/clang++ export CFLAGS=-fsanitize=address export LDFLAGS=-fsanitize=address xcodebuild CC=$CC CXX=$CXX OTHER_CFLAGS=$CFLAGS LDFLAGS=$LDFLAGS LDPLUSPLUS=$CXX CLANG_LINK_OBJC_RUNTIME=NO
You may need to open the Xcode GUI and copy the following file into the Linked Frameworks
/path/to/llvm/build/Release+Asserts/lib/clang/3.4/lib/darwin/libclang_rt.asan_osx_dynamic.dylib
FS2_Open must be run from the Terminal to enable to AddressSanitizer feature at runtime. Additionally, to ensure line references and the like are cleanly shown the output must be piped to a Python script which symobilizes line references
./FS2_Open\ \(debug\).app/Contents/MacOS/FS2_Open\ \(debug\) 2>&1 | /path/to/llvm/projects/compiler-rt/lib/asan/scripts/asan_symbolize.py | c++filt