Skip to content

Manual: Integrate in any App

lutzw edited this page Mar 14, 2013 · 6 revisions

This is a short guide aimed at helping you to include the PanicAR Framework in a new App (or in your existing one).

Prerequisites

this guide will not work for the older v1.05 version of PanicAR. The steps are largely the same, but you need to add a couple more frameworks, for example the OpenGL framework.

  • PanicARLib.framework (v1.20 version)
  • AR Assets folder

For the purpose of this tutorial we create a simple new App based on the Single-View App Template that comes with Xcode.

Step 1

1. Adding the PanicAR Framework

The App is called NewPanicARApp – the Xcode Project is open. Now drag and drop the PanicARLib.framework from Finder to XCode (you may add it anywhere, but adding it to the Frameworks-Group is recommended).

Step 1

2. Adding Required Frameworks / Dependencies

Go to the Build Targets Build Phases Tab and open the Link Binary with Librarys section:

Step 2

No add the following frameworks:

  • CoreLocation
  • CoreMotion
  • AVFoundation
  • MapKit (you can change the type on this one to "Optional")

Make sure the UIKit, Foundation and CoreGraphics Frameworks are also added to the Project.

It should look like this:

Step 2

3. Adding PanicAR Assets

Add the AR Assets folder by dragging it from Finder to XCode. The AR Assets include Marker Templates and default graphics for the Radar View.

Step 3

NOTE Delete the Sources Group after you added the AR Assets folder – it contains the Photoshop source files for the PNG files. You don't need it in your app.

4. Create PARViewController Subclass

Change the Base Class of your ViewController to PARViewController.

We do this in ViewController.h:

  • Add #import <PanicARLib/PanicARLib.h>.
  • Change the Base Class of ViewController to PARViewController.

Step 4

IMPORTANT If you try to build the App now, you get the following error (or along similar lines):

Undefined symbols for architecture i386:
  "___gxx_personality_v0", referenced from:
      Dwarf Exception Unwind Info (__eh_frame) in PanicARLib(PARController.o)
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Step 4

This is caused by the parts of the Framework which are written in native C code. In order for those parts to be linked correctly, we need to tell the compiler that our source files contain mixed-language source code.

That's done by giving any implementation file which uses objects defined in PanicARLib an .mm extension.

Step 4

5. Update XIB-Files

We need to update the XIB-Files and change the UIViews that Xcode automatically setup in them to PARViews.

Step 5

Just enter PARView as a Class for the View. Do this for the iPad and iPhone versions of the XIB.

6. Add Linker Flags

At this point the App will build without errors but will throw a bunch of unrecognized selector sent to instance errors (followed by crashs of the App) as soon as you run it.

To fix that, you have to add the -ObjC flag to the Other Linker Flags of the Target (and/or the Project). Select the Target's (or the Project's) Build Settings to do so.

Step 6

7. Add a Label at a POI

We do this in the viewDidLoadmethod of the ViewController:

// create a label for London
CLLocation* londonLocation = [[[CLLocation alloc] initWithLatitude:51.500141 longitude:-0.126257] autorelease];
PARPoiLabel* londonLabel = [[[PARPoiLabel alloc] initWithTitle:@"London" theDescription:@"United Kingdom" atLocation:londonLocation] autorelease];
[[PARController sharedARController] addObject:londonLabel];

Step 7

We're Done!

If you timed it we should hit the finish line in under an hour. Not bad, ey?

Step 8

Next Steps

  • Add the *ARController.strings file to the default localization of your project (it includes all the strings the ARController needs).
  • Edit DefaultPoiLabel.xib to change the look of the POI label.
  • Add [PARController deviceSupportsAR:YES] to the AppDelegate somewhere before loading the ViewController to check if the Device the App is running on supports Augmented Realtiy.
  • Implement the ARControllerDelegate protocol in ViewController and set ViewController to be the PARControllers delegate.
  • Use the ARControllerDelegate methods to add touch interaction to markers.

Download

Download the example project here: NewPanicARApp.zip

does not include framework – you have to add that to the project manually by copying the PanicARLib.framework file to the same folder the Xcode project is in.