A Swift Package Manager wrapper for the PNLight iOS SDK.
Add the following to your Package.swift file:
dependencies: [
.package(url: "https://github.com/pnlight-dev/sdk-swift.git", from: "0.1.1")
]Or add it directly in Xcode:
- Go to File → Add Packages...
- Enter
https://github.com/pnlight-dev/sdk-swift.git - Select the version you want to use
import PNLightSDK
// 1. Initialize the SDK (do this first)
await PNLightSDK.shared.initialize(apiKey: "your-api-key")
// 2. Validate a purchase (call before purchase - if false, don't proceed)
let isValidPurchase = await PNLightSDK.shared.validatePurchase() // captcha defaults to true
// Or disable captcha: let isValidPurchase = await PNLightSDK.shared.validatePurchase(captcha: false)
print("Purchase validation result: \(isValidPurchase)")
// 3. Log an event (example: user completed a tutorial)
await PNLightSDK.shared.logEvent("tutorial_completed", eventArgs: [
"level": "1",
"duration": "300",
"success": "true"
])- Initialization: Always initialize the SDK first before using any other methods
- Purchase Validation: Call
validatePurchase()before allowing a purchase. If it returnsfalse, it's better not to proceed with the purchase - Event Logging: Use
logEvent()to log events to the PNLight platform for analytics and tracking
The main SDK instance.
initialize(apiKey: String) async- Initialize the SDK with your API keyvalidatePurchase(captcha: Bool = true) async -> Bool- Validate a purchase with anti-bot protection. Set captcha to false to skip captcha challenge.logEvent(_ eventName: String, eventArgs: [String: Any]?) async- Log a custom event
- iOS 13.0+
- Swift 5.7+