Skip to main content
Use the Swift SDK to add PNLight to a native iOS app.

Requirements

  • iOS 13.0+
  • Swift 5.7+
  • Swift Package Manager

Install with Swift Package Manager

Package repository: pnlight-dev/sdk-swift. Swift SDK version Add it in Xcode:
1

Open package settings

In Xcode, click File and then Add Packages….
2

Enter the repository URL

Enter https://github.com/pnlight-dev/sdk-swift.git.
3

Add the package

Add the package to your app target.

Initialize the SDK

Initialize the SDK during app startup.
If you use Remote Config, provide local defaults during initialization:

Common calls

logEvent sends optional in-app events to PNLight. You can review them in Analytics → App Events, on the Events page, and in customer timelines.

Remote Config

Fetch Remote Config after initialization. Read values with typed getters and fallbacks your app owns.
By default, fetchAndActivate waits briefly for AppsFlyer attribution and uses a 15-minute minimum fetch interval. See Remote Config for fetch results, local defaults, and all supported value types.

IDFA after ATT

If PNLight initializes before the App Tracking Transparency prompt completes, call updateIdfa() after authorization so PNLight receives the granted IDFA.

Remote UI

Use RemoteUiView in SwiftUI when you want PNLight to render a placement you configured in the dashboard.
If you need to fetch the placement config yourself, use getUIConfig. On the first app launch, wait 4-5 seconds after AppsFlyer initialization when attribution is required. The SDK also waits for attribution internally when attributionRequired is true.
Use getUIConfigResult when your app needs to tell the difference between no UI for a placement and a loading error.
Use onPurchased when a schema v3 or v4 Remote UI document starts a purchase with pnlight.purchase and the app needs to refresh entitlements after StoreKit verifies it. See Remote UI for placement and action guidance.