API Reference
Log In

This section describes how to add MOCA iOS SDK to your app.

Minumum OS supported: iOS 10

Option A: Cocoapods

CocoaPods is a dependency manager for Objective-C projects. Learn more here.

  1. If you haven't already, install CocoaPods by executing the following:
$ sudo gem install cocoapods
  1. If you encounter any issues installing cocoapods, please refer to their getting started guide

  2. Create a plain text file named Podfile (or use touch Podfile from the command line) in the Xcode project directory with the following content:

target 'YOUR_TARGET_NAME' do
       pod 'MOCA', '~> 3.8.0'
end

Please check what is the latest version of the SDK by here

  1. Install MOCA SDK by executing the following in the Xcode project directory:
pod install
  1. Open the project workspace (<yourProject>.xcworkspace) instead of the project file (<yourProject>.xcodeproj) to ensure that the MOCA SDK dependency is properly loaded.

Swift additional steps

In order to use the MOCA Header symbols in your Swift application, you'll need to create a Bridging Header file.

1 - Download the file (or create a new one).
2 - Copy it to your Xcode project. Ensure you select "copy if needed" in the copy dialog box.
3 - Add the Bridging header to your Xcode Project.

📘

Ensure you have selected "All" options instead of "Basic"

Otherwise the option could remain hidden.

1497

Option B: Manual installation

  1. To install the MOCA SDK, download latest stable version of MOCA SDK archive.
  2. Xcode with the iOS development kit is required to build an iOS app using MOCA SDK. For a better experience, we recommend Xcode 12.
  3. Unzip the archive.

Once downloaded the SDK, you’ll need to add all necessary frameworks to your project.

  1. Open your project in Xcode.

  2. Add the libMOCALib.a static library provided in the SDK archive to your app project. The library is a universal FAT library compiled for the following architectures: armv7/armv7s/arm64/x86_64/i386.

  3. Make sure to Copy items into destination group's folder is selected.

  4. Press the Finish button.

  5. Ensure that you have added to your project the following dependent frameworks:

    • SystemConfiguration.framework
    • CoreTelephony.framework
    • MobileCoreServices.framework
    • CoreLocation.framework
    • UIKit.framework
    • AudioToolbox.framework
    • libsqlite3.0.dynlib
    • PassKit.framework (optional, only add if you plan to deploy Passbook cards)

    To do this, select your project file in the file explorer, select your target, and select the Build Phases sub-tab. Under Link Binary with Libraries, press the + button, to select and add all required frameworks.

  6. In Xcode, go to the Build Settings of your project. Next go to the “linking” section and add the flag –ObjC in Other Linker Flags.

846

Setting -ObjC linker flag.

Add the header files

  1. Copy the Headers folder from the decompressed file to your XCode project.
    • Ensure you check the "copy items if needed" so headers will be inside your project.
    • Select the needed target(s), so headers paths will be added automatically. (If you have only one target, select it).
723

🚧

Swift

When you add Objective-C header files into your Swift project, Xcode will ask you to create a Bridging Header file. This file allows Xcode to translate the Objective-C methods to Swift. This bridging file allows you to use MOCA SDK methods in Swift.

Xcode does not find the header files!

If you cannot #import <MOCA.h> within your AppDelegate, make sure Xcode has added the Header's path correctly to the project's configuration.

Go to <<Your Project Name>>/<<Your Build Target>>/Build Settings/Search Paths -> Header Search Paths and add the header's path. You can use the $(PROJECT_DIR) build setting to create relative paths:

802