Ad Quality SDK Swift integration for iOS

Integrate the Ad Quality SDK with Swift by creating a bridging header and initializing the SDK with your app key.

Read time 2 minutes

Ad Quality supports both Objective-C and Swift. While the SDK is written in Objective-C, you can make it compatible with Swift.

Step 1: Bridging Header

Swift and Objective-C use different runtime environments, you need a bridging header to access Objective-C code in Swift.

  1. Create a Bridging Header
    1. Inside Xcode, go to File > New > File.
    2. Select Header File under Source.
    3. Name it Ad-Quality-Bridging-Header.h and save it in your project.
  2. Link the Header in Build Settings
    1. Open Project Navigator and select your project target.
    2. Go to Build Settings.
    3. Search for Objective-C Bridging Header.
    4. Set the path to the bridging header:
      YourApp/Ad-Quality-Bridging-Header.h
      
  3. Import the Objective-C SDK into the Bridging Header
    1. Inside Ad-Quality-Bridging-Header.h, import the Objective-C SDK's main header file:
      #import "IronSourceAdQuality.h"
      

You can now use the Objective-C classes inside your Swift files.

For example:

import SwiftUI
@main
struct ironsourceadquality_sampleApp: App {
    init() {
        IronSourceAdQuality.getInstance().initialize(withAppKey: "YOUR_APP_KEY")
    }
}

You can now start integrating the Ad Quality SDK with Swift. Continue to Integrate Ad Quality SDK for iOS.