iOS documentation
IOSStream logs, crashes and user feedback from your iOS app to your LogWatcher server. Swift Package for iOS 12+ and macOS 10.15+. Persistent JSONL queue, uncaught-exception crash reporting. No dependencies.
Getting started
You need an application key. Create an account, add an app in the dashboard, and copy the key shown on its card. Every SDK call is tied to that key.
Install the SDK
The SDK is a Swift Package (source/client-sdks/ios/logwatcher-sdk).
Add it in Xcode (File → Add Package Dependencies…, pointing at the repository or a local checkout) or in Package.swift:
// Package.swift
dependencies: [
.package(path: "path/to/client-sdks/ios/logwatcher-sdk")
],
targets: [
.target(name: "YourApp", dependencies: ["LogWatcher"])
]
Platforms: iOS 12+, macOS 10.15+. No third-party dependencies.
Initialize
Activate once, as early as possible in the app lifecycle.
URL overrides must come before activate().
// Swift — e.g. in AppDelegate / @main init
import LogWatcher
LogWatcher.setApiUrl("https://fintechiq-logwatcher-19133922986.europe-west1.run.app")
LogWatcher.activate(appKey: "YOUR_APP_KEY", enableCrashReporting: true)
printToConsole (default true) mirrors every call to the Xcode console while you develop.
Send logs
One method per level. Logs are queued on-device and uploaded in batches; if the network is down they are retried later.
LogWatcher.d("PaymentFlow", "card inserted · reading chip")
LogWatcher.i("PaymentFlow", "auth approved · code 00")
LogWatcher.w("Network", "settle latency 2.1s — retrying")
LogWatcher.e("PaymentFlow", "auth declined · code 05")
LogWatcher.t("Lifecycle", "viewDidAppear") // trace
LogWatcher.f("Watchdog", "unrecoverable state") // fatal
For full control there is also
LogWatcher.log(line:method:file:level:tag:message:).
| Level | Method | Wire value |
|---|---|---|
| Debug | d() | 0 |
| Warning | w() | 1 |
| Error | e() | 2 |
| Trace | t() | 3 |
| Info | i() | 4 |
| Fatal | f() | 5 |
The non-sequential wire values are part of the LogWatcher wire protocol — the SDK handles the mapping.
Crash reporting
With enableCrashReporting: true the SDK installs an
NSUncaughtExceptionHandler (chaining any previous handler) and reports the exception name, reason and call stack.
Queued breadcrumb logs survive the crash on disk and upload on the next launch. Explicit reporting:
LogWatcher.sendCrash(title: "Checkout crashed", text: stackTrace)
Issues & user feedback
Report a noteworthy condition as an issue, or collect a message from the user.
Each call returns a URL? deep-linking to the item in your dashboard.
let url = LogWatcher.sendIssue(title: "Sync failed", text: "3 retries exhausted on /settle")
LogWatcher.sendUserFeedback(title: "From the merchant", text: "Receipt printed twice today")
Device key-values
Attach searchable properties to a device — a store number, a merchant id, a build flavour:
LogWatcher.setDeviceString(key: "store", value: "ATH-0042")
LogWatcher.setDeviceInteger(key: "lane", value: 2)
LogWatcher.setDeviceBoolean(key: "pilot", value: true)
LogWatcher.removeDeviceKey("pilot")
Remote device control
On every launch the SDK registers the device and receives its remote flags. From the dashboard you can enable log collection for a single device (a misbehaving terminal) while the rest of the fleet stays quiet — no release, no restart loop. To force collection locally regardless of the remote flag:
LogWatcher.setForceEnabled(true) // override the remote toggle
LogWatcher.forceSendOnce() // flush the queue right now
Advanced options
| Call | What it does |
|---|---|
setApiUrl(url) | Point the SDK at your server. Before activate(). |
setBaseUrl(url) | Base URL used to build dashboard deep-links. Before activate(). |
overrideDeviceName(name) | Report a custom device name. Before activate(). |
setMaximumLocalStorageSize(bytes) | Cap the on-device log queue (default 5 MiB); oldest entries are dropped first. |
deviceUrl / sessionUrl | Dashboard deep-links for this device / session (properties). |
forceSendOnce() | Flush the queue immediately. |
pendingLogCount() / isSessionStarted() | Diagnostics — queued rows and session state (useful in tests). |
On macOS the SDK reports os: "macos" and
device_type: "desktop"; batches are sent as raw JSON (the server also accepts gzip from other SDKs).