-
Notifications
You must be signed in to change notification settings - Fork 61
Manual: Integrate in any App 2.00
This is a short guide aimed at helping you to include the PanicAR Framework in a new App (or in your existing one).
this guide will only work for PanicAR v2.00 and later
- PanicARKit.framework (v2.x version)
- 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.
The App is called NewPanicARApp – the Xcode Project is open. Now drag and drop the PanicARKit.framework from Finder to Xcode (you may add it anywhere, but adding it to the Frameworks-Group is recommended).
Go to the Build Targets Build Phases Tab and open the Link Binary with Librarys section:
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:
Add the Assets folder by dragging it from Finder to XCode. The Assets include POI Label Templates and default graphics for the Radar View.
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.
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
toPARViewController
.
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)
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 PanicARKit an .mm extension.
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.
We do this in the viewDidLoad
method 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];
If you timed it we should hit the finish line in under an hour. Not bad, ey?
- Add the *PanicARKit.strings file to the default localization of your project (it includes all the strings the PARController 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 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.