Adding FMOD iOS API to Xcode 4.2

FMOD is an amazing resource for developers wanting to do advanced things with audio and want a layer of abstraction and a more streamlined approach. That being said, getting the API up and running for iOS in Xcode 4.2 was tricky. So, I wanted to post the process i followed to get the library working for me.
FMOD is a C++ library, so any header you import FMOD into must have a .mm (compiled as Objective-C++) implementation. That being said, any other files that are imported in the same file must be have .mm implementations as well.
You can grab the iOS build of FMOD at http://www.fmod.org/index.php/download. You can extract these files wherever you like. I placed mine in a directory I keep all my 3rd party libraries, but it’s really just a matter of preference.
First step is to open up terminal and cd to the directory you extracted the fmod api to. Now fire off the following command:
What we did was set the “install_name” for the libfmodex.dylib. To do so we use the command line program “install_name_tool”. Basically, we are defining a path to the dynamic library that the dynamic linker can use to find the library. There’s a great explination over at Bleeps and Pops: http://bleepsandpops.com/post/8447919182/adding-the-fmod-api-to-an-xcode-4-project
We need to tweak your “Build Settings”. Under your app target’s build settings, scroll to the “Linking” section. Under “Other Linker Flags” you will add -lfmodexL_$PLATFORM_NAME to Debug and -lfmodex_$PLATFORM_NAME to Release. All this does is turn on/off debug logging in the library. Make sure you have also added the CoreAudio and AudioToolbox frameworks.

In the same section, look for “Runpath Search Paths” and add “@loader_path/../Frameworks/” for both Debug and Release. We’ll talk about this more in a bit.
![]()
Still in “Build Settings”, find “Search Paths”. You will need to add the paths to the the FMOD “inc” and “lib” to your “Header Search Paths” and “Library Search Paths” respectively. Here’s where I have my paths pointing:
–> Search Paths Image
Next, we need to move over to the “Build Phases” tab. We need to link up our libfmodex.dylib. Under “Link Binary With libraries”, click the “+”, then click “Add Other…” and locate the libfmodex.dylib in the “api/lib” folder. After clicking “open” you will need to set it as “optional”. This allows fixes some issues with simulator importing the dylib. It should look like this:

Now, click the “Add Build Phase” at the bottom of this tab and select “Add Copy Files”. Set the Destination as “Frameworks”. Click the “+” and you should see the libfmodex.dylib in the list. Select it and click “Add”. This will copy the library into your application bundle when you deploy the app.

Click the “Add Build Phase” button again but this time select “Add Run Script”. In the code box add the following install_name_tool -change ./libfmodex.dylib @rpath/libfmodex.dylib “$TARGET_BUILD_DIR/$PRODUCT_NAME.app/$PRODUCT_NAME”

In one of you headers, import the fmod headers.
#import "fmod_errors.h"
Everything should compile successfully in simulator and device. I hope this saves somebody hours of trial and error becuase that’s about how I got to the solution!