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

In Xcode, choose File › Add Package Dependencies and add the package with Swift Package Manager:
Choose Up to Next Major Version from 0.1.0, the latest release, and link the Apsio product to your app target. In Package.swift: .package(url: "https://github.com/Apsio/apsio-apple-sdk", from: "0.1.0"). 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;
  • hangs while the app runs: the main thread blocked for more than 250 ms, with its stack;
  • slow and frozen frames per screen;
  • 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. Keep it to 16 to 256 letters, digits and + / = _ . : - (the hex below fits): that is the value you can erase the user by (Erasing a user). Requests for one user’s devices and live testers match a user by hash only from 16 characters (The user hash).
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. In the console, filter sessions and issues by a flag and variant, and see on an issue which variants’ sessions hit it most (By feature flag); agents get the same through get_issue_flags and the flag filters.

Replay

Replay records a wireframe of the screen, never pixels: view kinds, positions, styles, state and touches, sent in segments of up to a minute, at most 5 minutes per session (2 on Free; see how much is recorded). It is off until you turn it on, and only kept sessions are recorded; the remote configuration can turn it off without a release. See Replay and masking for the rules every SDK follows.

What is masked

Masking happens on the device, as the screen is read, and fails closed:
  • All text is masked by default, labels and button titles included: every character becomes x; spaces and line breaks stay.
  • Secure text fields are always masked; no setting shows them.
  • Images are boxes. Web views, maps, video and camera previews, and content drawn by another process (the keyboard among it) are hidden boxes.
  • A view of your app or a library that draws its own content (it overrides draw(_:), sets its layer’s contents, or draws text or a bitmap into a sublayer) is a hidden box; one with subviews is masked, with everything inside it.
  • SwiftUI draws into layers the SDK cannot read, so SwiftUI content is recorded as boxes without text or images. UIKit views inside SwiftUI, such as a TextField’s, are read as usual.
  • Touches are recorded only over what is shown: never over masked text (a PIN pad of plain buttons included), a secure field, the keyboard or a hidden box.
  • Past 2,000 views, the rest of the screen is one hidden box.

Your settings

On a UIKit view, call apsioReplayMask(), apsioReplayUnmask() or apsioReplayHide():
In SwiftUI, use the modifiers. .apsioReplayHide() records nothing of the view and no touches over it; .apsioReplayMask() masks the UIKit content inside it and hides touches over it. .apsioReplayUnmask() has no effect on SwiftUI content, which replay cannot read.
You can also put the token apsio-mask, apsio-unmask or apsio-hide in a view’s accessibilityIdentifier, as a whole word (see Tokens in an identifier):
Nothing inside a hidden view is recorded. A view’s own setting beats its class’s, and within one level hide beats mask, which beats unmask. The remote configuration can only add masking: its classes win over every setting of the app.

Class names

Class settings, yours and the remote configuration’s, match classes by the name NSStringFromClass gives, the class’s superclasses included. A Swift class carries its module: Checkout.CardField, not CardField. Passing the class itself, as in unmaskClasses: [PriceLabel.self] above, gets the name right. A hide or mask name that matches no class, a typo or a Swift class without its module, fails closed: the session is recorded in strict mode, with all text masked and images and views that draw themselves hidden. The device log shows a warning naming the classes, and the session gets an apsio.replay.strict_mode record listing them.

Check what is recorded

The preview tints over the app what replay records: red where it masks, grey where it hides, and a green outline where touches are recorded. It works whether or not the session records replay, and exists only in DEBUG builds. The capture runs only after something changed (a touch, a new screen, the keyboard), at most twice a second. Reading the views is its only work on the main thread, and it slows down when that takes more than 4 ms.
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. In your App Store privacy label, declare product interaction (screen views and taps, on by default), crash, performance and other diagnostic data, a device ID (the installation id), coarse location (the country and region derived on Apsio’s servers from the IP) and, with setUser(idHash:), a user ID: all linked to the user, none used for tracking. The label is your app’s own declaration, under Apple’s definitions: this is guidance, not legal advice. See App Store privacy labels.

Live inspection

Let your team watch this device live when your project marks its user or install as an internal tester: its log lines, memory and power state, and masked wireframes of the screen. Call it from your own setting, in internal and test builds:
It is off until the app turns it on, and the SDK keeps the choice across launches. It works before start and from any thread. It also needs consent and the installation id, and runs in the foreground only: it pauses while the app is interrupted and under Low Power Mode or Low Data Mode (where it sends nothing), and stops in the background. While anyone watches, the SDK shows “Your team is viewing this app live” above the app in each foreground scene, in a window of its own that takes no touch and never the keyboard. VoiceOver announces it each time it appears, and each notice. Wireframes come from replay’s capturer, so they need replay on; the battery is sent only with ApsioOptions(battery: true), which is off by default; live inspection never turns battery monitoring on. See Live inspection for what your team sees, the commands, the limits and privacy.

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