Skip to main content

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​

ModulePurpose
KapeCoreSDK initialization, configuration, keychain storage, logging, log upload
KapeAuthOpenID Connect authentication with PKCE
KapeVPN-PacketTunnelProtocol-agnostic tunnel core: session control, models and interfaces — no KapeClientSDK and no tunnel library dependency
KapeVPN-WireGuardWireGuard tunnel controller and configuration (KapeWireGuardConfig, PacketTunnelWireguardAuthenticator) — pulls in WireGuardKit
KapeVPNTunnel management: VPN profile, KapePacketTunnelProvider backed by KapeClientSDK, shared-state IPC. Re-exports KapeVPNDiscovery
KapeVPNDiscoveryAll 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-LightwayLightway tunnel controller and configuration — pulls in the Lightway library
KapeVPN-WireGuard-Bridge, KapeVPN-Lightway-Bridge, KapeVPN-OpenVPN-BridgeOne 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
info

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.

info

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​

RequirementMinimum
iOS16.0
tvOS17.0 — see tvOS
Swift5.9
Xcode15.4
DeviceReal device required for VPN (Simulator not supported)

tvOS​

tvOS differs from iOS in these areas:

FeatureOn tvOS
Sign-inDevice authorization flow instead of an in-app browser — see Authentication
Kill switchsetKillSwitchMode(_:) throws KapeError — see Network Protection
Connect on DemandNo .cellular rule condition — see Connect on Demand Rules
Wi-Fi identificationKapeNetworkHelper.ssid and .bssid are always nil — see Network Monitoring