Table of Contents

Enable EasyAR features in an iOS app

This chapter describes how to configure an EasyAR iOS project in Xcode without using a 3D engine such as Unity.

Preparation

Before you begin, prepare the following:

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 and does not 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 initialization code as follows:

    [easyar_Engine initialize:key];
    
  4. Privacy configuration

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

    campermission

    If screen recording is used, add Privacy - Microphone Usage Description to the privacy configuration.

    microphonepermission

Enable EasyAR through the Swift API

The EasyAR Sense Swift API is provided as source code, which provides the best compatibility (Apple has provided ABI compatibility since Swift 5).

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

Create an EasyARSwift framework project

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

    You can choose to embed the EasyARSwift project into your app project or create an independent project.

    embedprj

  2. Import EasyAR Swift code into the EasyARSwift project

    embedswiftcode2

    The EasyARSwift.h file automatically generated by XCode is not used and can be safely deleted.

  3. Configure Objective-C Bridging Header in build settings

    bridgeheader

    Note

    This option will not appear in XCode options before importing Swift files, so be sure to import the Swift code first before changing this configuration.

  4. Import easyar.xcframework into the EasyARSwift project

    addxframework3

  5. Disable Bitcode

    EasyAR does not use bitcode and does not provide bitcode compatibility, so make sure bitcode is disabled in the configuration. disablebitcode

  6. Deployment Target

    Modify deployment target according to your app project, and make sure the deployment target of the EasyARSwift project is less than or equal to that of the app project. setdeploytarget

Embed and use the EasyARSwift framework

  1. Embed the EasyARSwift framework in the project

    embedswiftfw embedswiftfw2

  2. import EasyARSwift in Swift source code

    importeasyswift

For coding style, refer to the code in the HelloARSwift sample or the API Reference.