Setting up EasyAR Sense for iOS¶
This article shows how to setup EasyAR non-Unity iOS projects using EasyAR package.
If you want to use EasyAR unity package, please read this for setup.
If you want to run EasyAR non-Unity iOS sample, please read this instead.
Pre-Requirements¶
XCode 10.1 or later (For the lowest version AppStore accepts, refer to Apple documentation)
ARM64-CPU-based iPhone or iPad device, or other real Apple devices (EasyAR do not support running on the simulator or ARMv7)
Static framework or dynamic framework¶
Static framework and dynamic framework are not official words from Apple. We use these phrases for convenience, to represent framework with static libraries and framework with dynamic libraries.
EasyAR Sense provides both static framework and dynamic framework.
If you are not familiar with Apple's dynamic framework, you can learn how to Embedding Frameworks In An App from Apple.
Some hints for choosing the framework,
Apple limits executable binary size when uploading to app store, so if you have a very large executable, you can choose dynamic framework, which will not increase the size of executable. Please notice that the total size of app will not change.
Execution time, performance or features will not be different when using different type of frameworks.
Static framework contains API stubs for x86, x86_64 and armv7, which can be used to build for simulator and ARMv7, but can not be used to run on them. Dynamic framework doesn't contains API stubs for x86 and x86_64, and contains only API stubs for armv7.
Add Frameworks¶
Static Framework¶
You need to add these frameworks when using EasyAR static framework.
easyar.framework
libc++.tbd
Accelerate.framework
AVFoundation.framework
CoreGraphics.framework
CoreImage.framework
CoreMedia.framework
CoreMotion.framework
CoreVideo.framework
OpenGLES.framework
UIKit.framework
ARKit.framework (add as optional)
Dynamic Framework¶
Only easyar.framework is required when using EasyAR dynamic framework.
easyar.framework
Do not forget to add easyar.framework in the Embedded Binaries list.
Disable Bitcode¶
EasyAR do not use bitcode and EasyAR do not offer bitcode compatibility.
Make sure to disable bitcode in your build settings,
Initialize EasyAR¶
Use initialize: method of easyar_Engine to initialize EasyAR. You can add the initialize into your code like this.
[easyar_Engine initialize:key];
Privacy Settings¶
Some privacy settings are required.
To use camera, add Privacy - Camera Usage Description,
To use screen recording feature, add Privacy - Microphone Usage Description,
Other Code¶
What is left is to write EasyAR logics and other code. You can refer to EasyAR samples for more details.
How to use Swift API¶
EasyAR Sense Swift API is provided in source code for the best compatibility (Apple provides ABI compatibility since Swift 5).
To use EasyAR Sense Swift API, you need to create a framework project and embed the generated framework target into your own project. EasyAR do not provide a pre-configured XCode project for this, because project settings may vary from different projects.
Create EasyARSwift framework project¶
Create a new project of type Cocoa Touch Framework and name it as EasyARSwift
You can choose to embed EasyARSwift project into your app project or create a sperate project.
Import EasyAR Swift code into EasyARSwift project
The EasyARSwift.h generated automatically by XCode is useless here, it is safe to remove it.
Setup Objective-C Bridging Header in build settings
Please note this option will not show in XCode before you import any Swift files into the project, so make sure to import swift code first.
Import static easyar.framework into EasyARSwift project for link
Add Linked Frameworks and Librarires
You need to add these frameworks when using EasyAR static framework.
easyar.framework
libc++.tbd
Accelerate.framework
AVFoundation.framework
CoreGraphics.framework
CoreImage.framework
CoreMedia.framework
CoreMotion.framework
CoreVideo.framework
OpenGLES.framework
UIKit.framework
ARKit.framework (add as optional)
Disable Bitcode
EasyAR do not use bitcode and EasyAR do not offer bitcode compatibility.
Make sure to disable bitcode in your build settings,
Deployment Target
Change deployment target to fit your app project, make sure it is lower than or equal to your app project.
Embedding and use EasyARSwift framework¶
Embedding EasyARSwift framework into your project
import EasyARSwift in Swift source code
You can reference HelloARSwift sample code or API Reference for how to use.