Setting up boost in Xcode

By | October 6, 2013

Here’s how I have set up boost in Xcode 5:

  1. Build and install boost
  2. Set the search paths in Xcode
  3. Add the .dylib file to the project
  4. Make sure the project is linking with the .dylib file
  5. Create a copy phase to copy the .dylib to the appropriate place


1. Build and Install Boost

You can more or less follow the instructions on boost website. I chose to compile with clang and libc++ because, well, let’s face it, c++11 is kinda cool.

Also, note that I’m building the debug libraries, as this library will be used mostly for development. For release mode, you can change the variant to “release.”

2. Set the search paths in Xcode

Let’s assume that you have already set up an Xcode project.
To add boost headers and dylib files to your project’s search path, go to your project build settings:
And add /path/to/boost/include to “Header Search Paths” and /path/to/boost/lib to “Library Search Paths.”

2. Add the .dylib file to the project

Add the dynamic (or static) lib file to the Xcode project.
Here, I’ve added the boost serialization library.

4. Link with the new .dylib

Make sure that you are actually linking to the boost library that you just added.
Note, this step may have happened automatically when you added the .dylib file to the project.

5. Create a copy phase

Add a new copy files build phase, and make sure that the boost .dylib files are copied to the appropriate locations.

That’s about it!

3 thoughts on “Setting up boost in Xcode

  1. Andrew Norris

    Best instructions yet! Thanks!! Only prob I had was an error when running. This was fixed (in step 4 above) by setting to “Optional” instead of “Required”. Perhaps I needed this because my projects was a cocoa app not a command line tool, that’s the only difference I can see between our two projects. Many thanks!!

  2. Georg

    I did all how written in this tutorial, but it don’t solve my problem with “error Do not compile Asio library source with BOOST_ASIO_HEADER_ONLY”


Leave a Reply

Your email address will not be published. Required fields are marked *