Using Leap Motion in an Objective-C project

Leap Motion

I have started learning about Leap Motion and decided to make a simple app in Objective C in order to test it. The first thing I realise it is that there is no template for Objective C, nor a guide of how to integrate the lib and setup the project. So here I will show how to set up an OS X project, and also I will provide a template.

  1. Once you create your project, drag and drop Leap.h LeapMath.h LeapObjectiveC.h LeapObjectiveC.mm into your project and check «Copy items into destination group’s folder (if needed)». Also check that files are added to your main target and «Create groups for any added folders» is selected.
  2. Copy libLeap.dylib into your project folder.
  3. Select your project and add libLeap.dylib as a required framework.
  4. Now let’s create a new Build Phase in order to copy libLeap.dylib into the executable. Go to your main target, click on «Build Phases» and add a «Copy Files Build Phase». The destination must be set to «Executables».
  5. Last, but not least, go to «Build Settings», look for «C++ Standard Library» and make sure «libstdc++ (GNU C++ standard library)» is selected.

The class EALeapMotionController implements the interface LeapDelegate where all the events are handled.
Download template project