# Installing and configuring the SDK

Release version **1.7.5** | Release date **10/20/2025**

{% hint style="info" %}
Minimum requirements:

* iOS 13.0 and above.
* Use Xcode 13 and above.
  {% endhint %}

## Demo application

Use our demo application as an example.

{% embed url="<https://github.com/MadexTech/madex-ios-demo>" %}

## Installation

### General description of the installation process

To install the iOS SDK, you will need:

* Check out the demo application
* Finalize the `Podfile` of your project
* Run `pod instal`l in the project folder
* Check the installation correctness by initializing the SDK with debug mode enabled

### Podfile Configuration

{% hint style="warning" %}
Minimum required CocoaPods version is 1.10.0 or higher. You can find more detailed information about CocoaPods updates [here](https://guides.cocoapods.org/using/getting-started.html).
{% endhint %}

1. Add dependencies to your `Podfile` for the installation of all necessary adapters.\
   \
   The account manager at Madex will provide you with a full list of dependencies along with the current version numbers for libraries and adapters. \
   \
   Example dependencies for Madex, Yandex, IronSource, and Mintegral networks:

```ruby
platform :ios, "13.0"

target "Sample" do
    use_frameworks!
    
    # connection of Madex SDK dependency
    pod "MadexSDK", "1.7.5"
    
    # connection of Applovin SDK advertising network dependency
    pod "SspnetApplovinAdapter", "1.4.0"
    
    # connection of IronSource SDK advertising network dependency
    pod "SspnetIronSourceAdapter", "1.4.0"
    
    # connection of Yandex SDK advertising network dependency
    pod "SspnetYandexAdapter", "1.4.0"
    
    # connection of Mintegral SDK advertising network dependency
    pod "SspnetMintegralAdapter", "1.4.0"
end
```

2. Save the file and open the terminal in the project folder.
3. Run the command `pod install` in the terminal to install the dependencies.

{% hint style="info" %}
Use the `pod update` command to update dependencies.
{% endhint %}

### Add the Applovin SDK key

If you are using an adapter for Applovin, then add the following key to the `Info.plist`:

```swift
<key>AppLovinSdkKey</key>
<string>APPLOVIN_SDK_KEY</string>
```

You can copy your APPLOVIN\_SDK\_KEY in the "Keys" section of your Applovin [personal account](https://dash.applovin.com/o/account?r=2#keys).

### Installation check

To make sure that the SDK is installed correctly, you will need to enable debug mode and initialize the SDK.

### Debug mode

In debug mode SDK logs errors and events. It is disabled by default.

Use the `enableDebug` method to enable debug mode.

```swift
Madex.enableDebug(true);
```

### Initialization

Use the code below to initialize the SDK in your project.

You can copy your `publisher_id` in the "Settings" section of your Madex [personal account](https://publisher.madex.world/).

```swift
Madex.initialize(publisherID: "publisher_id") { error in
    if let error {
        // Called when the SDK is installed correctly
        // Using AdException error, you can get detailed information about the error
    } else {
        // Called when an error occurred during SDK installation  
    }
}
```

If the SDK is installed correctly, you will see the following message in the console.

```swift
SDK initialized(<Madex SDK version number>)
```

Done! The SDK is installed, you can proceed to [setting up ads](https://madex.gitbook.io/madex-documentation/ios-sdk/working-with-advertising).

We recommend that you don't disable debug mode until you finish working with ads.

### If the SDK is installed incorrectly

In case of errors, we recommend clearing the `CocoaPods` cache.

The command to clear the cache is provided below.

```swift
rm -rf "${HOME}/Library/Caches/CocoaPods"
rm -rf "`pwd`/Pods/"
pod update
```

If this doesn't help, try installing the SDK in a clean project. If the SDK is installed correctly, try to debug errors in your project.

We also recommend to take a look at the installation and initialization in the [demo application](https://github.com/MadexTech/madex-ios-demo).

If you are unable to install the SDK correctly and the above steps didn't lead to successful initialization, please contact support.

## Additional actions to increase revenue

### Setting Up Apple ID

For more effective targeted advertising and increased revenue, Madex SDK collects and transmits user [App ID](https://developer.apple.com/help/account/manage-identifiers/register-an-app-id/) data - a unique numerical application identifier from the Apple AppStore.

It is determined automatically, but in some cases, Madex SDK may not be able to determine it.

If Madex SDK did not determine your App ID, you will see the following message in the console.

```
AppStore ID is nil. You must set AppStore ID manually.
```

In this case, you need to set the ID manually.

To set up Apple ID, use the `setCustomParams` method.

```swift
Madex.setCustomParams("appStoreAppID", "apple_id")
```

Replace `apple_id` with your App ID from the AppStore developer account. You can find it on the app page in the [developer account](https://appstoreconnect.apple.com/).

<figure><img src="https://626582791-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwiiOaJhSveT4OR9bjTvw%2Fuploads%2F3d8NCA9Hhb1P8wy8kSy1%2Fimage.png?alt=media&#x26;token=48a6af1b-4e34-4bb3-87b5-1bb801ec6b64" alt=""><figcaption><p>Using an Apple ID in the AppStore Connect</p></figcaption></figure>

### Apple Advertising Identifier (IDFA)

For more effective targeted advertising and increased revenue, you can collect the Apple device advertising identifier and pass it to Madex SDK.

To enable IDFA collection, add descriptions for the following permissions to the `Info.plist` file:

`NSUserTrackingUsageDescription` - Permission to collect the advertising identifier (Advertising Identifier IDFA).

The sample code in the `Info.plist` file is provided below.

```markup
<key>NSUserTrackingUsageDescription</key>
<string>We need this permission for better ad targetting</string>
```

### Geolocation data collection

To make targeted ads work more effectively and increase revenue, you can collect in app data about a user's exact and/or approximate geolocation, and feed it into the Madex SDK.

To enable data collection, add descriptions for the following permissions to the `Info.plist` file:

`NSLocationWhenInUseUsageDescription` - Permission to collect user geolocation.

The sample code in the `Info.plist` file is provided below.

```xml
<key>NSLocationWhenInUseUsageDescription</key>
<string>We need this permission for better ad targetting</string>
```

## Other SDK settings

### User Consent Screen

In order to comply with the requirements of the app store and the laws governing the collection, processing and use of user's personal data, it is required to obtain his consent to the above actions.

Usually, the user's consent is obtained on a special screen when the application is first launched — consent-screen.

The Madex SDK implements such a screen, you can add and configure it using the Content Manager library.

You can find out more about its installation and configuration in the corresponding section.

{% content-ref url="user-consent-screen" %}
[user-consent-screen](https://madex.gitbook.io/madex-documentation/ios-sdk/user-consent-screen)
{% endcontent-ref %}
