# Quick start

> This topic introduces how to quickly set up Alipay+ MPP iOS SDK.

This topic introduces how to quickly set up the Alipay+ iOS SDK.

## Before you begin

Before you get started, ensure that the following requirements are met:

-   Install Xcode 12.\* or later.
-   Ensure that the minimum deployment target is set to iOS 9 or later.

## Step 1: Add the SDK to your project

1.  Log on to [Alipay+ Developer Center](https://connect.alipayplus.com/account/signin?goto=https%3A%2F%2Fdevelopers.alipayplus.com%2Fopen%2Fconsole%2Fdeveloper%2Fapp%2Flist%3F_route%3DSG&terminal_type=pc&locale=cn&loginId=&from_site=GN) to download the SDK binaries as a package. You can also obtain the source code if you need to review or customize the SDK source code. The following table lists the SDK packages that are required for different Alipay+ payment products:

| Product | Product | Merchant-presented Mode Payment | Auto Debit |
| --- | --- | --- | --- |
| Framework | Foundational | - MPPAlipayPlusClient.framework - IAPTinyLogger.framework | - MPPAlipayPlusClient.framework - IAPTinyLogger.framework |
| Framework | Product-specific | - MPPAlipayPlusClientMPM.framework - IAPMinContainer.framework | - MPPAlipayPlusClientAutoDebit.framework |
| Product-specific bundle | Product-specific bundle | - IAPMinContainer.framework/IAPMinContainer.bundle | N/A |

2.  Ensure that the SDK is linked to your project.

-   If you use [CocoaPods](https://cocoapods.org/) to publish your SDK, add the following lines to your podspec file:

```objectivec
s.subspec 'Foundation' do |ss|
    ss.vendored_frameworks=  ["YOUR_PATH/MPPAlipayPlusClient.framework", "YOUR_PATH/IAPTinyLogger"]
end

s.subspec 'MPM' do |ss|
    ss.vendored_frameworks=  ["YOUR_PATH/MPPAlipayPlusClientMPM.framework", "YOUR_PATH/IAPMinContainer.framework"]
    ss.resources = ["YOUR_PATH/IAPMinContainer.framework/IAPMinContainer.bundle"]
    ss.dependency "YOUR_POD/Foundation"
end

s.subspec 'AutoDebit' do |ss|
    ss.vendored_frameworks=  ["YOUR_PATH/MPPAlipayPlusClientAutoDebit.framework"]
    ss.dependency "YOUR_POD/Foundation"
end
```

-   If you do not use CocoaPods, you can manually add the SDK as follows:

1.  Add the required framework and bundle files to your project based on the product you use. Make sure to select **Copy items if needed**.

> **Note**: The SDK provides the privacy manifest file in _IAPMinContainer.bundle_. The privacy manifest file is required for integrating third-party SDKs on the iOS platform. For more information, see [_Privacy manifest files_](https://developer.apple.com/documentation/bundleresources/privacy-manifest-files).

(1) Merchant-presented Mode Payment

![image](https://idocs-assets.marmot-cloud.com/storage/idocs87c36dc8dac653c1/1698379084557-7db5e056-d435-4a86-becb-c7c305f1652b.png)

(2) Auto Debit

![Screenshot 2023-10-27 at 11.59.34.png](https://idocs-assets.marmot-cloud.com/storage/idocs87c36dc8dac653c1/1698379180999-41ba9fb2-a53d-4a3c-86c9-33826a061f36.png)

b. Add **\-ObjC** to **Build Settings** > **Linking** > **Other Linker Flags** to use the class category.
![image](https://idocs-assets.marmot-cloud.com/storage/idocs87c36dc8dac653c1/1698379251759-ca2da614-14f5-4eb2-bbf5-67d4cd465789.png)

> **Note**: If you use Swift and encounter the error `Undefined symbol: ___llvm_profile_runtime` during the build, add **\-fprofile-instr-generate** to **Build Settings** > **Linking** > **Other Linker Flags**.

## Step 2. Set up the SDK before using other APIs

1.  Import the SDK header file to your project.

```objectivec
import <MPPAlipayPlusClient/MPPAlipayPlusClientAPI.h>
```

2\. Set up the SDK with the required configurations.

```objectivec
MPPConfiguration *configuration = IAPConfiguration.new;
configuration.clientId = @"XXX";
configuration.envType = @"PROD";
configuration.siteName = @"YYY";
[[MPPAlipayPlusClient shared] setConfiguration:configuration];
```

> **Note**: When configuring the SDK in the sandbox environment, set _configuration.envType_ to `PROD`.

## Step 3: (Optional) Configure log monitoring

To track activity lifecycles within the SDK, initialize the monitoring component using the following code:

```swift
#import <IAPTinyLogger/IAPTinyLogger.h>

// Listen to log type
[IAPTinyLogger setLogEnabled:YES forType:IAPTinyLogTypeEvent];
[IAPTinyLogger setLogEnabled:YES forType:IAPTinyLogTypeException];
[IAPTinyLogger setLogEnabled:YES forType:IAPTinyLogTypeDiagnose];
[IAPTinyLogger addObserver:YOUR_OBSERVER];

// Setting up observer
@objc_class YOUR_OBSERVER
- (void)logger:(IAPTinyLogger *)logger didCollectLog:(IAPTinyLog *)log {
    // Print log.name and log.parameters
}
@end
```

## Next steps

After you have integrated the SDK, refer to the following guides to implement specific payment scenarios:

-   [Merchant-presented Mode Payment integration](../integration_merchant_mode_mpp/integration).
-   [Auto Debit integration](../integration_auto_debit_mpp/integration).