Skip to content

Instantly share code, notes, and snippets.

@Mulperi
Created April 4, 2019 16:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mulperi/e251903936cc81cb390a132ad21830a1 to your computer and use it in GitHub Desktop.
Save Mulperi/e251903936cc81cb390a132ad21830a1 to your computer and use it in GitHub Desktop.
Xcode and Box2D setup

Xcode and Box2D setup

  1. Download and unzip the Box2D source code from https://github.com/erincatto/Box2D

  2. Install premake5 from https://premake.github.io/download.html and move the executable to /usr/bin/ so it is in your PATH.

  3. Go to the unzipped folder and build the library from command line with premake xcode4

  4. From resulting Build folder, get libBox2D.a which is the library archive file and the whole Box2D folder that has the header files and place them to your Xcode project folder so that the dependencies folder is one level up from the main.cpp and other source files.

  1. Select Build Phases and Link Binary With Libraries add new item and search for the libBox2D.a file from the project sub folder.

  2. On Xcode, select the project file and then on the Build Settings tab, select TARGETS and your target application name. Add Header Search Path: ${PROJECT_DIR}/dependencies/Box2D/include

  3. Add this source code and try building to see if the library linking works

    #include "Box2D/Box2D.h"
    int main(){ return 0; }
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment