iOS ARToolKit Xcode Implementation - ios

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.
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?

Give the correct location of <AR/ar.h> file.
For example:
#import "../ARAppCore/EAGLView.h"

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
3. Open your project in Xcode
4. Drag the ARToolKit5iOS.xcodeproj into your project
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
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. *
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.

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
You can fix the issue by adding 'Header search path' on target of your new app.Please go through the following image.

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:
Download ARToolKit5-bin-5.3.2-iOS.tar.gz and unpack it.
Open ARToolKit5iOS.xcodeproj
In Xcode go to File -> New -> Target
Choose Cocoa Touch Framework, enter Product Name, set language to Objective-C, set Embeed in Aplication to None
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
Go to Build Settings and set Automatic Reference Counting to No
Create new PCH File (prefix header) for you Framework target
In Build Settings set Precompile Prefix Header to YES and in Prefix Header set path to PCH file that you have created
In created PCH file add imports: #import <Foundation/Foundation.h> and #import <UIKit/UIKit.h>
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
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.

Related

Integrating Unity in Swift project

Well, I have seen and tried most of tutorials referenced from similar questions "How to integrate Unity iOS code into Swift project". But all my attempts were failed with linker error "No such symbol for architecture arm_64" or "No such symbol for architecture x86_64". I have tried different build options in Unity side, no success.
Common minus of all of that tutorials / articles is: all of them outdated, latest version of Unity I have found article is 2018.2.2f1, my version of Unity is 2018.2.20f1.
So, anyone have idea how integrate Unity 2018.2.20+ iOS builded code into Swift 4.2 (XCode 10) project?
Any help will be great appreciated.
Here is how I have integrated unity in my swift project.
Create new Xcode project (using swift)
(create bridging header step) Create new class File -> New -> Cocoa touch class and select language Objective C it will ask for create bridging header choose create
Goto https://github.com/jiulongw/swift-unity and download zip file
Open downloaded file and unzip it. Go to Xcode folder -> DemoApp-> You will find Unity Folder copy paste to your project (if you drag and drop it make sure you check the check box for copy at destination)
open your new Xcode project and auto generated unity project side by side so you can copy paste it easily
copy Classes Folder from unity Xcode project to your Xcode project to the unity Folder of step 4
copy Library Folder from unity Xcode project to your Xcode project to the unity Folder of step 4
copy Data Folder from unity Xcode project to your Xcode project to the unity Folder of step 4
Important Goto Xcode project tap on name of project on left side there will be two options Project and target. Select project on centre main window you can see Configuration Expand it and against the name of your project choose Unity from drop drown
Goto Classes Folder that you have copied in step
And either delete main.mm file or comment everything
goto folder you have downloaded in step3 Copy all code of AppDelegate.swift to your AppDelegate.swift file
In your Xcode project search for YourProjectFileName-Bridging-Header and copy paste
#ifndef BRIDGING_HEADER
#define BRIDGING_HEADER
#import <UIKit/UIKit.h>
#import "UnityUtils.h"
#import "UnityAppController.h"
#import "UnityInterface.h"
#endif /* BRIDGING_HEADER */
Copy paste LaunchScreen-iPad.xib and LaunchScreen-iPhone.xib to your project and delete LaunchScreen.storyboard
Compile it :] it should compile successfully (not in my case I got error that DeviceSettings.mm there is return statement missing so I just added return deviceUnknown; before the })
You can see step3 downloaded view controller.swift file for see how to show unity view in your screen
Notes: After integrate unity you are not able to run in simulator so you have to run in real device.
it is better to have unity and xcode in same machine. sometime all the framework only get ref of folder so in different machine you may face the issue
at last your project should look like

Xcode picks wrong version of header file with same name

A similar question has been asked and answered here, however the solution provided does not solve my problem.
My Project has two targets: A Cocoa Framework (macOS) and a Cocoa Touch Framework (iOS).
The Frameworks share a lot of source files and headers, but there are files that are specific to each framework (due to platform differences).
In particular, both frameworks each have a class named ViewController.
On iOS, it is declared like this:
($(SRC_ROOT)/Platforms/iOS/ViewController/ViewController.h:)
#import <UIKit/UIKit.h>
#interface ViewController : UIViewController
...
On the Mac, like this:
($(SRC_ROOT)/Platforms/macOS/ViewController/ViewController.h:)
#import <Cocoa/Cocoa.h>
#interface ViewController : NSViewController
...
I also have a third class, Manager, that is common to both platforms.
It is just a subclass of NSObject and thus its header file only needs to import the platform-agnostic <Foundation/Foundation.h>.
But this class's methods interact with the aforementioned ViewController, so the implementation file imports that header:
($(SRC_ROOT)/Common/Manager.m:)
#import "Manager.h"
#import "ViewController.h" // <-- THIS
#implementation Manager
...
Now, when I build the iOS target everything is fine.
But when I try to build the macOS target, the iOS version of ViewController.h gets somehow imported and I get the following error:
Lexical or Preprocessor Issue - 'UIKit/UIKit.h' file not found
...pointing at the #import statement in Manager.m.
Some more information:
ViewController.h is a public header in both frameworks, and is included in the umbrella headers for both targets:
#import <MyFramework/ViewController.h>
Each version of the header has target membership set to the appropriate target.
For both targets, Header Search Paths and User Header Search Pathsis blank, and Always Search User Paths is NO.
I have tried to set Header Search Paths to each of the following values, to no avail:
$(SRC_ROOT)/Platforms/macOS/
$(SRC_ROOT)/Platforms/macOS/**
./Platforms/macOS/
./Platforms/macOS/**
I tried deleting the iOS version of the header temporarily, and the build succeeded. But after restoring the file and cleaning the build folder, it fails again.
How can I get Xcode to "see" the right version of the header, on the Mac target?
EDIT: I tried the same path values from point (4) for "Framework Search Paths". Same error.
UPDATE:
If I set the build setting Always Search User Paths to YES (the default is NO), my framework builds. I can even build a sample Mac app that links to it and it runs. However, I get the warning:
Warning: using 'ALWAYS_SEARCH_USER_PATHS = YES' while building targets
which define modules ('DEFINES_MODULE = YES') may fail. Please migrate
to using 'ALWAYS_SEARCH_USER_PATHS = NO'.
...but I read somewhere this would cause trouble down the line (can't find the post now).
UPDATE 2:
If, in addition, I change the build setting Defines Module to NO (as suggested by the warning), both the framework and the app that embeds it build succesfully, and the framework's classes are available (i.e., instantiable) from the app's code.
However, I fear this whole "not defining a module" business is going to cause trouble when I attempt to use my framework from an app written in Swift...?

Issue with setting up iOS push notifications because AppDelegate.h isn't finding a needed header

I'm following instructions for push notification setup for iOS. Instructions can be found here:
https://azure.microsoft.com/en-us/documentation/articles/notification-hubs-ios-get-started/
I am at the step where I must:
Open your AppDelegate.h file add the following import directives:
#import <WindowsAzureMessaging/WindowsAzureMessaging.h>
#import "HubInfo.h"
However, I get the following error:
http://imgur.com/xk2Rngh
Here is my file outline:
http://imgur.com/PStisNu
Any idea what I am doing wrong? The mistake is probably very simple. Obviously the Azure header file is present in the header folder, but possibly my syntax is off in some way
After you've downloaded your frameworks, you should place it in your project folder.
After that you should go to Build Settings -> Runpath Search Paths and add $(PROJECT_DIR)
It shows Xcode, where to search for these frameworks
After all of that you just add them to the Xcode project itself
Btw, you can place these frameworks anywhere you want, but you should provide a valid search path for Xcode to find them.

Framework header file not found (iOS pop framework)

I'd like to install facebook's pop framework. I have a multi-project workspace which is not using cocoa pods. I want just the simplest, dumbest, quickest install.
From the pop readme:
"... you can add the project to your workspace and adopt the provided configuration files or manually copy the files under the pop subdirectory into your project. If installing manually, ensure the C++ standard library is also linked by including -lc++ to your project linker flags."
I added pop.xcodeproj to my workspace.
I added "pop.framework" to to
the project that needs pop (general > linked frameworks and libraries).
I added "-lc++" to my project linked flags (in the project that needs pop).
Added #import <POP/POP.h> to my .m file.
The result: "POP/POP.h" not found.
I guess I'm doing something wrong, but absolutely no idea where to start looking.
I set the Built Setting of my project, then it worked.
User Header Search Paths = $(SRCROOT) // recursive. Pop is placed in the directory
Always Search User Paths = YES
This setting worked for me:
in podfile:
pod 'pop'
in project > target > build settings
always search user paths YES
add search path:
Take a look at this:
How to add facebook open source code pop to project directly
I also discovered that the -lc++ flag actually caused a linker error. I followed the instructions in that link and removed the flag and everything worked!
You could try this...worked for me as I'm also adding pop as static library, instead of using CocoaPods:
Download source code from this tutorial, because we'll be adding the library files with quotes "POP/POP.h" instead of < POP/POP.h > and all files are already changed here, just copy/paste the "pop" folder from the example project to your project: http://tapity.com/tutorial-getting-started-with-pop/ You can alternatively change all files you already have inserting quotes.
In your project create a subdirectory called "pop" (File/New/Group) with another subdirectory inside called "WebCore". It's important that you create these subdirectories so they will appear as yellow "folders" (instead of blue folders) and Xcode will compile the files properly. You can check if POP files are being included in Build Phases / Compile Sources.
Add the respective POP files inside these empty subdirectories respecting the same structure of the source project (i.e. File/Add Files to "project" inside each subdirectory).
Now just #import "POP/POP.h" and start using pop animations. Doing this way there's no need to add pop.xcodeproj to your workspace.
After trying all of these solutions, what worked for me was actually was lowering the Deployment Target from 9.3 to 8.0.
Be careful of the order of your framework search paths. I had another project which I was referencing modules from that had a different version of the framework library and because that project was higher in the framework search path ranking it was picking up the incorrect header files too.
Those who suffers from it. My problem was like this,
I was having trouble with swift and xcode 8 build times. So i changed my scheme Edit Scheme -> Build -> Find Implicit Dependencies (Uncheck). I was not get trouble with simulator i was having trouble with device. So when i change it to check again it worked. And then made uncheck or vice versa.

Adding FTUtils to an iOS Project

I am trying to add FTUtils to my iOS project but even though I have added the "FTUtils.xcodeproj" project to my own custom project I am not able to make a reference to the
#import <FTUtils/FTAnimation.h>
I followed the setup from this link: http://ftutils.com/docs/setup
When I drag the FTUtils.xcodeproj into my own project it does not ask me anything. Also the documentation says that check mark the libFTUtils.a. What checkbox are they talking about?
This answer is a little bit late, but, the only thing that you have to do is to drag this files to your project :
FTUtils.h
FTAnimation.h
FTUtils+NSObject.h
FTAnimationManager.h
FTAnimation+UIView.h
FTUtils+UIGestureRecognizer.h
In Build Phases tag ---> Link Binary with libraries add:
libFTUtils-fat.a
Then you have to import to your class:
#import "FTAnimation.h"
#import "FTAnimation+UIView.h"
And use it like (with the effect/Animation you want to use, of course):
[self.view slideOutTo:kFTAnimationLeft inView:self.view duration:1.0 delegate:nil startSelector:nil stopSelector:nil];
I just dragged the .m and .h files into my project. I prefer to have the source instead of the library so I can edit it. I have added a number of my own animations to it.
But if you prefer to use the static library, I believe you open FTUtils.xcodeproj, build it then drag the .a file it will build and .h files into your project.

Resources