Ad Quality iOS SDK Swift Integration

Ad Quality supports both Objective-C and Swift. While the SDK is written in Objective-C, you can easily 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.
Note:
We plan to roll out an updated SDK that will simplify your integration and remove the need of adding a bridging header manually.
Once this change is live we’ll update you on our SDK Change log.

    1. Create a Bridging Header
      • Inside Xcode – Go to FileNewFile.
      • Select Header File under Source.
      • Name it Ad-Quality-Bridging-Header.h and save it in your project.
    2. Link the Header in Build Settings
      • Open Project Navigator and select your project target.
      • Go to Build Settings.
      • Search for Objective-C Bridging Header.
      • Set the path to the bridging header:
        YourApp/Ad-Quality-Bridging-Header.h
        • Light theme
        • Dark theme
        • Copy to clipboard

    3. Import the Objective-C SDK into the Bridging Header
      Inside Ad-Quality-Bridging-Header.h, import the Objective-C SDK’s main header file:
      #import "IronSourceAdQuality.h"
      • Light theme
      • Dark theme
      • Copy to clipboard


Step 2: Use the SDK in Swift

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")
    }
}
  • Light theme
  • Dark theme
  • Copy to clipboard

Done!

 What’s Next?

You are now all set to start integrating the Ad Quality SDK with Swift!
Continue to Integrate Ad Quality SDK for iOS.