3

I'm trying to implement ARToolKit into an Objective-c iOS app.

I have downloaded the ARToolKit SDK and I see the following contents. The ARToolKit5 directory is for Mac OSX, so I have left this one closed. ARToolKit5iOS is the directory that I have tried to import into my Xcode project.

ARToolKit SDK contents

What I have tried so far...

Inside share > packaging, I ran the following command and this seemed to run correctly without any errors.

bash ARToolKit5iOS-bin.sh

Then I tried to import the lib and include directories into my Xcode project.

The problem

Here is the contents of my project > ViewController.m

#import "ViewController.h"
#import <AR/ar.h>

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end

As you can see in the following screenshot, the error occurs whilst trying to import the AR toolkit.

I am not an Objective-c developer, so what am I missing here?

enter image description here

4 Answers4

0

Give the correct location of <AR/ar.h> file.

For example:

#import "../ARAppCore/EAGLView.h"
Saranjith
  • 11,242
  • 5
  • 69
  • 122
0

Here's what you do:
1. Download iOS SDK on ARToolKit's Download page
2. Unzip the archive and move the folder to where your Xcode project is in the file system enter image description here 3. Open your project in Xcode
4. Drag the ARToolKit5iOS.xcodeproj into your project enter image description here 5. Select your project on the left panel, click on your app target, then in Build Phase, add various AR targets as dependencies and link libraries enter image description here 6. In Build Settings, under Search Paths, add "Library/ARToolKit/include/" and "Library/ARToolKit/include/ios7" to Header Search Paths. Also, add "Library/ARToolKit/lib" and "Library/ARToolKit/lib/ios7" to Library Search Paths. * enter image description here

  • This path will differ depending on where you put the ARToolKit sdk and how you name the folder. As you can see in the phone in Step 2. I add Library folder and put everything under the folder "ARToolKit". Plus, the Library folder is at the same level as the ARExperiment.xcodeproj file. Thus, when referencing them, I have to put "Library/ARToolKit/" first.
Lance Fu
  • 31
  • 2
0

I also integrate ARToolKit library to new iOS project after long research.

Need to add lib, include and ARAppCore to our project. Please note the following image when we add the folders to your project

enter image description here

You can fix the issue by adding 'Header search path' on target of your new app.Please go through the following image.

enter image description here

IKKA
  • 6,297
  • 7
  • 50
  • 88
0

You can create a framework target and separately build a framework that you will later put into your application (which will also work with a swift app). To do this you will need to start as follow:

  1. Download ARToolKit5-bin-5.3.2-iOS.tar.gz and unpack it.
  2. Open ARToolKit5iOS.xcodeproj
  3. In Xcode go to File -> New -> Target
  4. Choose Cocoa Touch Framework, enter Product Name, set language to Objective-C, set Embeed in Aplication to None
  5. Go to ARFramework target Build Phases, you will configure it according to ARApp target that is:
    • in Build Phases in Target Dependencies add: AR, ARICP, ARvideo, ARgsub_es2
    • in Compile Sources add: ARAppCore/EAGLView.m, ARApp/ARViewController.m, ARView.m
    • in Link Binary With Libraries add: Accelerate.framework, libAR.a, libARICP.a, libARvideo.a, libARgsub_es2.a
  6. Go to Build Settings and set Automatic Reference Counting to No
  7. Create new PCH File (prefix header) for you Framework target
  8. In Build Settings set Precompile Prefix Header to YES and in Prefix Header set path to PCH file that you have created
  9. In created PCH file add imports: #import <Foundation/Foundation.h> and #import <UIKit/UIKit.h>
  10. If your framework need to be bitcode enabled then set Enable Bitcode in Build Settings of you framework target and targets: AR, ARICP, ARvideo, ARgsub_es2
  11. Your framework target should now Build successfully so you can check Product -> Build on your framework target

Note that in ARViewController.m from ARApp that you added to the framework there are two hardcoded paths to camera_para.dat and hiro.patt files which are needed in this example to detect hiro marker. To solve this you can for example add those two files to you application and edit ARViewController.m to search them in main bundle so for example edit lines that load them in the ARViewController.m to:

char *patt_name = [[NSBundle mainBundle] pathForResource:@"hiro" ofType:@"patt"].UTF8String;

and

char *cparam_name = [[NSBundle mainBundle] pathForResource:@"camera_para" ofType:@"dat"].UTF8String;

or implement some custom reading depending on your needs. In your app on storyboard set viewcontroller class to ARViewController and thats it, framework should now work fine and scan hiro marker in your custom app and show a cube on top of it. Also note that this is just an example of how to copy ARApp functionality into framework that can be attached in your app and this framework will not have any visible interfaces so this is just the basic work you will need to do to integrate it with basic single marker detection functionality.

Leszek Szary
  • 9,763
  • 4
  • 55
  • 62