Note: This repository is the Swift Package Manager (SPM) mirror for the worldcoin/idkit monorepo (
swift/directory). The Swift sources are generated via UniFFI, giving Swift clients the exact same surface area as the Rust core. Please open issues and pull requests in the main repository.
Swift SDK for World ID verification.
- Xcode 16+
- iOS 15+ / macOS 12+
Add the package to your project using SwiftPM:
.package(url: "https://github.com/worldcoin/idkit-swift", from: "4.0.2")import IDKit
// 1. Build RP context from your backend (never expose your signing key on the client)
let rpContext = try RpContext(
rpId: "rp_1234567890abcdef",
nonce: backend.nonce,
createdAt: backend.createdAt,
expiresAt: backend.expiresAt,
signature: backend.sig
)
// 2. Configure the request
let config = IDKitRequestConfig(
appId: "app_staging_1234567890abcdef",
action: "login",
rpContext: rpContext,
actionDescription: "Verify Humanity",
allowLegacyProofs: true,
environment: .production
bridgeUrl: nil,
overrideConnectBaseUrl: nil,
)
// 3. Build and send the request
let request = try IDKit
.request(config: config)
.preset(orbLegacy(signal: "user-123"))
// 4. Generate a QR code with this URL and scan it with World App
print("Connector URL:", request.connectorURL)
// 5. Poll for the result
let completion = await request.pollUntilCompletion()
switch completion {
case .success(let result):
// Verify this in your backend
print("Verified", result)
case .failure(let error):
print("Failed", error.rawValue)
}| Entry point | Description |
|---|---|
IDKit.request(config:) |
Build and send a verification request |
The request object exposes:
connectorURL: URL— URL for the World App QR coderequestID: UUID— unique request identifierpollStatusOnce()— check status oncepollUntilCompletion(options:)— poll until success or failure (configurablepollIntervalMsandtimeoutMs)
Use the World ID Simulator for development testing before going to production. Configure IDKit with environment: .staging when using the simulator.