1. Adding the SDK to Your App

There are 3 ways to add the SDK to your app:

CocoaPods

👍

You’ll know the SDK has been added to your app successfully when:

  • Podfile.lock file has been created in the project folder;
  • A file with the .xcworkspace extension has been created in the project folder;
  • Pods widget containing a Mindbox folder has been created in the xCode Project navigator.
544

To add Mindbox’s SDK to your app from Cocoapods, open the Podfile in your app’s root directory and specify the required guide.

If the Podfile is missing there, run pod init from the project folder to initialize Cocoapods.

Next, add the dependency to your main app: target '<your app name>', making sure that the use_frameworks! guide is at the beginning of the Podfile.

We recommend that you specify the latest iOS SDK version published on Mindbox’s GitHub Releases.

use_frameworks!

...

target '<your app name>' do
  ...
  pod 'Mindbox', '{latest release}'
    # pod 'Mindbox', '2.1.5'

end
1540

Run pod install in the terminal.

Open a .xcworkspace file in xCode.

Carthage

👍

You’ll know the SDK has been added to your app successfully when a Frameworks folder with Mindbox.xcframework has been created in the Xcode Project navigator.

544
  1. Make sure you’ve closed Xcode.

  2. Using the terminal (cd path/to/project), go to your project’s folder.

  3. Run touch Cartfile to create a Cartfile.

  4. Enter echo 'github "https://github.com/mindbox-cloud/ios-sdk.git"' → Cartfile in your Cartfile.

  5. Execute carthage update --no-use-binaries --use-xcframeworks:

    • For Xcode 11 or earlier, run carthage update --no-use-binaries. Note that all the .xcframework examples should have the .framework extension in the instruction.
  6. Open your project in Xcode.

  7. Select the main Target in the project settings. Open the "General" tab.

  8. Drag your Mindbox.xcframework folder from <YOUR PROJECT'S DIRECTORY>/Carthage/Build to "Frameworks, Libraries, and Embedded Content".

  9. If you add the file using the "+" button, a window appears: select Create folder references and click Finish.

1492

Swift package manager

👍

You’ll know the SDK has been added to your app successfully when a Mindbox develop package has been created in Package Dependencies.

526
  1. Open the top menu in Xcode and go to "File" → "Add Packages...".
  2. Enter the link to Mindbox’s SDK: https://github.com/mindbox-cloud/ios-sdk.
  3. Select a relevant release (1.3.3 supports Swift Package Manager) and click Add Package.
  4. Once the package has been downloaded, add Mindbox to the main project target.
3248

👍

Check your results:

  • Podfile.lock has been created in the project folder;
  • A .xcworkspace file is created in the project folder, and
  • Pods widget with a Mindbox folder is created in the xCode Project navigator.