iOS SDK
The Kape iOS SDK provides a native Swift API for building VPN-enabled iOS applications. It wraps the Low Level SDK and provides high-level modules for authentication, VPN connectivity, and server discovery.
Modules
| Module | Purpose |
|---|---|
| KapeCore | SDK initialization, configuration, keychain storage, logging, log upload |
| KapeAuth | OpenID Connect authentication with PKCE |
| KapeVPN-PacketTunnel | Protocol-agnostic tunnel core: session control, models and interfaces — no KapeClientSDK and no tunnel library dependency |
| KapeVPN-WireGuard | WireGuard tunnel controller and configuration (KapeWireGuardConfig, PacketTunnelWireguardAuthenticator) — pulls in WireGuardKit |
| KapeVPN | Tunnel management: VPN profile, KapePacketTunnelProvider backed by KapeClientSDK, shared-state IPC. Re-exports KapeVPNDiscovery |
| KapeVPNDiscovery | All location discovery — KapeLocationService (locations, Smart Locations, ping, DIP inspection, geo) and KapeVPNDiscoveryService (protocol-explicit locations, full OpenVPN endpoint configuration + OpenVPN credentials). Depends on KapeCore only, links none of the tunnel libraries |
| KapeVPN-Lightway | Lightway tunnel controller and configuration — pulls in the Lightway library |
| KapeVPN-WireGuard-Bridge, KapeVPN-Lightway-Bridge, KapeVPN-OpenVPN-Bridge | One per VPN protocol: connects KapePacketTunnelProvider to that protocol. Opt-in — list it in vpnProtocols; see Installation. Each also takes your own authenticator — see Custom Authentication |
Import only what your target needs:
import KapeCore // Always required in the app
import KapeAuth // For authentication
import KapeVPN // For VPN connectivity (app + default PacketTunnel extension)
// or
import KapeVPN_PacketTunnel // PacketTunnel extension with a custom endpoint generator
// or
import KapeVPNDiscovery // Locations + OpenVPN endpoint config, no tunnel dependencies
KapeVPNDiscovery is also pulled in — and re-exported — by KapeVPN, so apps that import KapeVPN
already see KapeVPNDiscoveryService. Import the product directly only when you want a target that
does not link the tunnel libraries. See
OpenVPN Endpoint Configuration.
KapeVPN links no VPN protocol. With KapePacketTunnelProvider, add one KapeVPN-<Protocol>-Bridge product per protocol and list it in vpnProtocols (see Installation). With KapeVPN_PacketTunnel alone, import KapeVPN_WireGuard / KapeVPN_Lightway / KapeVPN_OpenVPN instead, inject its connection controller to KapeSessionController, and generate a KapeWireGuardConfig / LightwayConfiguration / OpenVPNConfiguration to connect to.
Quick Example
let settings = try KapeSDKSettings() // reads KapeSDK.plist
let handle = try KapeSdkHandle(settings: settings)
let auth = KapeAuthClient(handle: handle)
try await auth.login(presenting: viewController)
try handle.activateSubscription(for: .custom(values: ["xv.vpn"]))
let locations = KapeLocationService(handle: handle)
try await locations.fetchLocations()
let vpn = KapeVPNManager(handle: handle)
try await vpn.installProfile()
try await vpn.connect(to: locations.allLocations.first!.id)
Requirements
| Requirement | Minimum |
|---|---|
| iOS | 16.0 |
| tvOS | 17.0 — see tvOS |
| Swift | 5.9 |
| Xcode | 15.4 |
| Device | Real device required for VPN (Simulator not supported) |
tvOS
tvOS differs from iOS in these areas:
| Feature | On tvOS |
|---|---|
| Sign-in | Device authorization flow instead of an in-app browser — see Authentication |
| Kill switch | setKillSwitchMode(_:) throws KapeError — see Network Protection |
| Connect on Demand | No .cellular rule condition — see Connect on Demand Rules |
| Wi-Fi identification | KapeNetworkHelper.ssid and .bssid are always nil — see Network Monitoring |