Setting up EasyAR Sense for iOS

This article shows how to setup EasyAR non-Unity iOS projects using EasyAR package.

If you want to run EasyAR non-Unity iOS sample, please read this instead.

Pre-Requirements

  • XCode 13 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, but may provide libraries containing only API stubs for the ease of convenience for compilation.)

Add Frameworks

Add easyar.xcframework in Frameworks, Libraries, and Embedded Content.

  • easyar.xcframework

../_images/image53.png

Disable Bitcode

EasyAR do not use bitcode and EasyAR do not offer bitcode compatibility.

Make sure to disable bitcode in your build settings,

../_images/image54.png

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,

../_images/image55.png

To use screen recording feature, add Privacy - Microphone Usage Description,

../_images/image56.png

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

  1. Create a new project of type Cocoa Touch Framework and name it as EasyARSwift

    ../_images/image91.png ../_images/image92.png

    You can choose to embed EasyARSwift project into your app project or create a sperate project.

    ../_images/image93.png
  2. Import EasyAR Swift code into EasyARSwift project

    ../_images/image94.png

    The EasyARSwift.h generated automatically by XCode is useless here, it is safe to remove it.

  3. Setup Objective-C Bridging Header in build settings

    ../_images/image95.png

    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.

  4. Import easyar.xcframework into EasyARSwift project for link

  5. Disable Bitcode

    EasyAR do not use bitcode and EasyAR do not offer bitcode compatibility.

    Make sure to disable bitcode in your build settings,

    ../_images/image54.png
  6. Deployment Target

    Change deployment target to fit your app project, make sure it is lower than or equal to your app project.

    ../_images/image96.png

Embedding and use EasyARSwift framework

  1. Embedding EasyARSwift framework into your project

    ../_images/image97.png ../_images/image98.png
  2. import EasyARSwift in Swift source code

    ../_images/image99.png
  3. You can reference HelloARSwift sample code or API Reference for how to use.