Add X-Auth to a SwiftUI or UIKit app via Swift Package Manager. Call advice() from a tap handler with full async/await ergonomics.
In Xcode: File → Add Package Dependencies… and paste the URL. Or add it to Package.swift:
.package(url: "https://github.com/xentranet/x-auth-ios", from: "1.0.0")Build the SDK once, hold it in your app's environment.
import SwiftUI
import XAuth
@main
struct TransferApp: App {
let xauth = XAuth(tenantId: "your-app")
var body: some Scene {
WindowGroup {
TransferView().environment(xauth)
}
}
}advice() from a SwiftUI buttonPull the SDK from the environment, call advice, and POST the bearer to your backend.
import SwiftUI
import XAuth
struct TransferView: View {
@Environment(XAuth.self) var xauth
var body: some View {
Button("Transfer $29.99") {
Task {
let advice = try await xauth.advice(
action: "transfer", amount: 2999, currency: "USD"
)
guard advice.decision == .allow else { return }
var req = URLRequest(url: URL(string: "https://api.example.com/transfer")!)
req.httpMethod = "POST"
req.setValue("Bearer \(advice.accessToken)",
forHTTPHeaderField: "Authorization")
_ = try await URLSession.shared.data(for: req)
}
}
}
}Use any backend SDK to call verify() and assert the bound action matches.
const { transaction_ctx } = await xauth.verify(bearer, {
expect: { action: 'transfer', amount: req.body.amount },
});Pair with a backend quickstart: Express, Go, Spring Boot, ASP.NET.
Configure step-up methods (FaceID for biometric, push for out-of-band) and tune your risk policy.