Mac SDK Setup

Integrate Paddle’s SDK into your Xcode project

Requirements

  • The Mac v4 SDK requires Mavericks (OSX 10.9) or above
  • The SDK is written in Objective C but also has a Swift interface
  • The user’s OS must support TLS 1.2

Overview

Paddle’s Mac SDK has two primary components: the main Paddle class where most functions are centralized and the PADProduct class which represents a Paddle product for you to work with them in your app.

Paddle Singleton (Paddle)

  • The base class of the Paddle SDK. This is responsible for configuration and control, initialize the SDK, control the UI, and trigger actions like license recovery.

Paddle Product (PADProduct)

  • A local representation of a Paddle product or subscription, with details including remaining trial days, activation date, prices and actions on the Product to refresh its data from the seller dashboard and verify or deactivate a license.
  • Paddle Products have a dependency on the Paddle Singleton, please ensure you initialize the singleton first.
  • You can have multiple PADProduct instances for multiple product IDs instantiated at once.

Xcode Setup

1. Add to Project

Add the Paddle framework to your Xcode project by dragging from the Finder.

2. Add to Target

3. Copy Files

Within Build Phases add a build phase (New Copy Files Build Phase). Make sure Destination is set to Frameworks.

4. Sandbox Settings

If your app is sandboxed you should enable Outgoing Connections in your Signing & Capabilities tab to allow the framework to send data to Paddle.

5. Initialize Product

The Paddle SDK requires that you initialize it with an SDK Product, which you’ll need to create via the Vendor Dashboard. Once initialized you can work with any type of Product or Subscription, we’ll never assume the SDK Product used to initialize the SDK is the relevant one.

Import the Paddle Singleton to your class:

@import Paddle
// or
#import <Paddle/Paddle.h>

Then configure and initialize the SDK and your Product.

// Your Paddle SDK Config from the Vendor Dashboard
NSString *myPaddleVendorID = @"12345";
NSString *myPaddleProductID = @"678910";
NSString *myPaddleAPIKey = @"1234abc5678defg";

// Default Product Config in case we're unable to reach our servers on first run
PADProductConfiguration *defaultProductConfig = [[PADProductConfiguration alloc] init];
defaultProductConfig.productName = @"My v4 Product";
defaultProductConfig.vendorName = @"My Company";

// Initialize the SDK singleton with the config
Paddle *paddle = [Paddle sharedInstanceWithVendorID:myPaddleVendorID
                                             apiKey:myPaddleAPIKey
                                          productID:myPaddleProductID
                                      configuration:defaultProductConfig
                                           delegate:nil];
								
// Initialize the Product you'd like to work with	  
PADProduct *paddleProduct = [[PADProduct alloc] initWithProductID:myPaddleProductID
                                                      productType:PADProductTypeSDKProduct
                                                    configuration:defaultProductConfig];

// Ask the Product to get its latest state and info from the Paddle Platform
[paddleProduct refresh:^(NSDictionary * _Nullable productDelta, NSError * _Nullable error) {
	// Optionally show the default "Product Access" UI to gatekeep your app
	[paddle showProductAccessDialogWithProduct:paddleProduct];
}];

Debug Mode

Enable Paddle’s debug mode in your app by adding the following line:

[Paddle enableDebug];

Debug mode prints more verbose information and error messages to the console while the app is running and also adds an additional app menu, allowing you to reset or expire app trials.