Table of Contents

Enable EasyAR features in iOS applications

This chapter describes how to configure the EasyAR iOS project in Xcode without using 3D engines such as Unity.

Preparation

Before you start, you need to prepare:

Enable EasyAR with Objective-C

  1. Add frameworks

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

    addxframework1

  2. Disable bitcode

    EasyAR does not use bitcode nor provide bitcode compatibility, so bitcode needs to be disabled in the configuration.

    disablebitcode2

  3. Initialize EasyAR

    Use the initialize: method of easyar_Engine to initialize EasyAR. You can add the initialization code as follows:

    [easyar_Engine initialize:key];
    
  4. Privacy configuration

    Since AR requires the use of the camera, the privacy configuration needs to add Privacy - Camera Usage Description.

    campermission

    If you want to use the screen recording feature, the privacy configuration needs to add Privacy - Microphone Usage Description.

    microphonepermission

Enable EasyAR through the Swift API

The EasyAR Sense Swift API is provided in source code form, offering the best compatibility (Apple has provided ABI compatibility since Swift 5).

To use the EasyAR Sense Swift API, you first need to create a framework project and then embed the framework target into your project.

Create easyarswift framework project

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

    You can choose to embed the EasyARSwift project within your app project or create a separate project.

    embedprj

  2. Import EasyAR Swift code into the EasyARSwift project

    embedswiftcode2

    The auto-generated EasyARSwift.h file by Xcode is unused and can be safely deleted.

  3. Configure Objective-C Bridging Header in build settings

    bridgeheader

    Note

    This option won’t appear in Xcode settings until swift files are imported, so ensure swift code is imported before modifying configuration.

  4. Import easyar.xcframework into the EasyARSwift project

    addxframework3

  5. Disable Bitcode

    EasyAR doesn’t use bitcode nor provide bitcode compatibility. Ensure bitcode is disabled in configurations.
    disablebitcode

  6. Deployment Target

    Adjust deployment target according to your app project, ensuring the EasyARSwift project’s deployment target is ≤ the app project’s.
    setdeploytarget

Embed and use EasyARSwift framework

  1. Embed EasyARSwift framework in the project

    embedswiftfw
    embedswiftfw2

  2. In Swift source code, import EasyARSwift

    importeasyswift

For code writing methods, refer to the code in the HelloARSwift sample or API Reference.