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: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 SwiftUIApp initializer, or in
application(_:didFinishLaunchingWithOptions:).
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).
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).
setAttribute is added to every record from then on; nil removes it.
AttributeValue).
Logs, errors and breadcrumbs
- Log levels are
.trace,.debug,.info,.warn,.errorand.fatal. Logs below the minimum level of the remote configuration (Info by default) are dropped on the device. recordErrorrecords a handled error with its stack. Errors are grouped into issues like crashes;fingerprintreplaces the default grouping. See Crashes and issues.- Breadcrumbs are the steps shown before a crash or an error in the same session.
Spans
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
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, callapsioReplayMask(), apsioReplayUnmask() or apsioReplayHide():
.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.
apsio-mask, apsio-unmask or apsio-hide in a view’s
accessibilityIdentifier, as a whole word (see Tokens in an identifier):
Class names
Class settings, yours and the remote configuration’s, match classes by the nameNSStringFromClass 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
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.
Privacy and consent
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: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:completionHandler on the main thread. handleBackgroundEvents returns false
for background sessions that are not Apsio’s; handle those as before.
Next
- Upload your dSYMs, so crashes show function names and lines.
- Remote configuration: sampling and capture without a release.