Skip to main content
API preview: names may change before 1.0.

Requirements

  • iOS or iPadOS 15.0 or later.
  • Swift Package Manager, with Xcode 16 or later. Your app can use the Swift 5 or the Swift 6 language mode; the snippets on this page are checked in Swift 6 mode.

Install

Add the package https://github.com/Apsio/apsio-apple-sdk with Swift Package Manager and link the Apsio product to your app target. There is no tagged release yet; during early access, use the main branch. The package depends on KSCrash 2.6.0 for crash capture. If your app already links KSCrash, Swift Package Manager resolves one copy.

Start

Start Apsio as early as possible: in your SwiftUI App initializer, or in application(_:didFinishLaunchingWithOptions:).
Calling start again does nothing. The app key is not a secret: it ships inside your app and only routes data to your project.

What is recorded

From then on Apsio records, with nothing else to do:
  • crashes, sent when the app next launches;
  • terminations without a crash report (out of memory, watchdog), inferred on the next launch;
  • app start time, and screen load times for UIKit view controllers;
  • network requests made with URLSession: method, URL without the query string, host, status and duration;
  • breadcrumbs for screens, network requests and app lifecycle changes;
  • sessions, and the daily MetricKit reports (launch, hangs, memory, CPU, terminations).
Crashes are not recorded while Xcode’s debugger is attached: the debugger stops the app first. To test a crash, stop the app in Xcode and open it from the home screen.

Options

traceparent is only added to the hosts you list, never to third parties. Query strings and request bodies are never recorded.

Users and attributes

Identify the user with a hash you compute. Never pass an email or a name.
An attribute set with setAttribute is added to every record from then on; nil removes it.
Attribute values are strings, booleans, integers, doubles or string arrays (AttributeValue).

Logs, errors and breadcrumbs

  • Log levels are .trace, .debug, .info, .warn, .error and .fatal. Logs below the minimum level of the remote configuration (Info by default) are dropped on the device.
  • recordError records a handled error with its stack. Errors are grouped into issues like crashes; fingerprint replaces the default grouping. See Crashes and issues.
  • Breadcrumbs are the steps shown before a crash or an error in the same session.

Spans

Spans started while another is open become its children.

Screens in SwiftUI

UIKit view controllers are tracked on their own, named after their class. In SwiftUI, name screens yourself, and report when a screen shows its real content to measure its time to full display:

Feature flags

The flag and its variant are attached to the session and to crashes.
The choice is kept across launches. If your app must ask before anything is collected, call start only after the user agrees. The SDK ships a privacy manifest for each of its modules. Declare crash, performance and diagnostic data in your App Store privacy label; if you keep the installation id on, also declare a device ID used for analytics, not linked to the user and not used for tracking. See Privacy and consent.

Sending now

Records leave in batches. To send what is queued now, for example before a test ends:

Background uploads

What is left when the app moves to the background is handed to iOS, which sends it later. Optionally, let iOS know when Apsio’s uploads finish:
Apsio calls completionHandler on the main thread. handleBackgroundEvents returns false for background sessions that are not Apsio’s; handle those as before.

Next