Skip to content
Docs/SDKs

iOS (Swift)

Experimental source reference. Zero third-party dependencies — URLSession + Foundation. iOS 12+ / tvOS.

Experimental — verify runtime eligibility

Requires an Apple build environment. Public package access, device rendering and production eligibility remain unverified. Public package: Not verified. Source version: 1.0.0. See availability and capability evidence.
PackageTheaimartAdx
LanguageSwift
DistributionSource only; public installation not verified
RequirementsXcode / a Swift toolchain on macOS to build; iOS 12+ at runtime.

Install

Source setup — accessible SDK checkout required

bash
# Use packages/ios/Package.swift from an accessible SDK checkout; a public root Swift package was not verified.

Usage

Drop-in banner + manual render

swift
import TheaimartAdx

let adx = Adx(apiKey: "pk_your_publisher_key")

// Option A — drop-in banner:
let banner = BannerAdView(frame: CGRect(x: 0, y: 0, width: 300, height: 250))
banner.load(adx, request: AdRequest(slotID: "8b1f2c3d-....-uuid"))
view.addSubview(banner)   // viewability + click handled automatically

// Option B — request + render yourself:
adx.requestAd(AdRequest(slotID: "8b1f-uuid")) { ad in
    guard ad.filled else { return }
    // render ad.creative ...
    // After rendering and measuring actual viewability:
    // if ad.isTrackable { adx.reportViewable(ad.impID) }
}
Requires an Apple build environment. Public package access, device rendering and production eligibility remain unverified.

Production hardening

  • Fraud-safe User-Agent theaimart-adx-ios/<ver> (iPhone|iPad; iOS <ver>) — off the backend bot blocklist, with a device token so the backend classifies correctly.
  • SQL-filter-safe encoding of free-text params so real URLs never trip the WAF.
  • 4-way union parsing (internal / openrtb / house / no-fill) and fail-closed rendering.

These behaviors come directly from the wire contract — see User-Agent rules and WAF-safe encoding for why they matter. Not getting fills? See Troubleshooting.

API

MemberNotes
Adx(apiKey: String)Construct a client.
adx.requestAd(_ request: AdRequest, completion: (Ad) -> Void)Request an ad decision.
adx.reportViewable(_ impID: String)Fire the viewability beacon.
BannerAdView(frame:).load(_ adx:, request:)Drop-in banner with automatic viewability + click.

The normalized Ad model

Same normalized Ad shape as the other SDKs (filled, kind, source, impID, creative, auction, isTrackable).

Build & test

bash
cd packages/ios
swift build
swift test          # Encoding + Models unit tests (XCTest)

BannerAdView requires UIKit (device/simulator); the AdxEncoding and Ad parsing logic is covered by unit tests.