-
Download and unzip the Box2D source code from https://github.com/erincatto/Box2D
-
Install premake5 from https://premake.github.io/download.html and move the executable to
/usr/bin/
so it is in your PATH. -
Go to the unzipped folder and build the library from command line with
premake xcode4
-
From resulting
Build
folder, getlibBox2D.a
which is the library archive file and the wholeBox2D
folder that has the header files and place them to your Xcode project folder so that the dependencies folder is one level up from themain.cpp
and other source files.
-
Select
Build Phases
andLink Binary With Libraries
add new item and search for thelibBox2D.a
file from the project sub folder. -
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
-
Add this source code and try building to see if the library linking works
#include "Box2D/Box2D.h" int main(){ return 0; }