The following steps will walk you through adding the RevTwo library to your app in Xcode.
The easiest way to add the RevTwo library is to include it with Cocoapods.
New to CocoaPods? Here is how to install
CocoaPods is a dependency manager for Swift and Objective C projects. To learn more, see the full CocoaPods documentation. If you already have CocoaPods installed in your project you can skip this section.
CocoaPods is built with Ruby and is installable with the default Ruby available on macOS. To install CocoaPods, in terminal run the command:
$ sudo gem install cocoapods
Start using CocoaPods on your existing project
To start using CocoaPods in your project, open the terminal app and go to your project directory.
If you aren’t familiar with the terminal app, try navigating to your Xcode project in finder. Open the terminal app, and type “cd ” into the console. This is the command to change directories. From finder, drag the folder for your Xcode project into the terminal app. This will copy in the folder’s path. Hit enter to run the command, this will put you in the directory that your app is in.
From your project’s directory, run the command:
$ pod init
This command creates the Podfile for the project. The Podfile is where you will specify the libraries you want to use.
Add the RevTwo Pod
Go to the folder where your Xcode project is and open your Podfile. Add these lines to your project’s Podfile:
The full Podfile should look something like this:
# Uncomment this line to define a global platform for your project # platform :ios, '6.0' target 'RevTwoSample' do pod "RevTwo" end target 'RevTwoSampleTests' do end
Now navigate to your project in the terminal app and run the command:
$ pod install
If this is the first pod you are using, this command will create a .xcworkspace file. From now on, open this file in Xcode instead of the .xcodeproj file.
Go into the project Build Settings, make sure “All” is selected, and scroll down to Build Options. Change the property “Enable Bitcode” to “NO”.
If you don’t see this property, remember to select “All”. You can use the search field to find the property faster.
Adding the Product Key
Put the following code in your UIApplicationDelegate‘s application DidFinishLaunchingWithOptions method. The product key is in the admin portal on your app’s model page.
// add your RevTwo product key here R2Initialize(@"ADD YOUR KEY HERE", @"YOUR SECRET KEY" R2MODE_DEVELOPMENT, YES);
Make sure you import RevTwo.h in your AppDelegate.m file if you’re using objective-c.
Run your app. You should see your device show up in the connected apps page.