| Package | TheaimartAdx |
|---|---|
| Language | Swift |
| Distribution | SwiftPM / CocoaPods |
| Requirements | Xcode / a Swift toolchain on macOS to build; iOS 12+ at runtime. |
Install
Swift Package Manager
swift
.package(url: "https://github.com/theaimartco/theaimart-adx-sdks.git", from: "1.0.0")
// then add product "TheaimartAdx" to your target (path: packages/ios)CocoaPods
ruby
pod 'TheaimartAdx', '~> 1.0'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 ...
if ad.isTrackable { adx.reportViewable(ad.impID) }
}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
| Member | Notes |
|---|---|
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.