Add Crash Reporting to a Swift iOS App with AppAmbit
Watch this step-by-step tutorial to add crash reporting to a Swift iOS app with AppAmbit. Install the SDK with CocoaPods, connect your app with an App Key, trigger a real crash, and inspect the full report — stack trace, affected users, device, and session data — in the dashboard. Complete SwiftUI integration in under 10 minutes.
Watch the full tutorial or read the summary below
Overview
In this tutorial, we'll add crash reporting to a Swift iOS app with AppAmbit. We'll install the SDK with CocoaPods, connect the app, and trigger a real crash. Then we'll verify the report in the dashboard and inspect the crash details. By the end, you'll have the complete flow working in under ten minutes.
What You'll Learn
- How to install the AppAmbit SDK with CocoaPods
- Connecting a SwiftUI app with your App Key
- Triggering a real, uncaught crash for testing
- Verifying the crash report in the dashboard
- Inspecting stack traces, affected users, and device details
Prerequisites
Before you begin, make sure you have:
- A SwiftUI iOS app project open in Xcode
- An AppAmbit account (sign up for free)
- Your app's unique App Key from the dashboard
- CocoaPods installed on your machine
Confirm the App Builds
Start with a clean SwiftUI application running in Xcode. Before adding AppAmbit, run it once to confirm that it builds normally. The app is intentionally simple, so the integration stays easy to follow.
Copy Your App Key
In AppAmbit, open the iOS application you want to monitor. From the Info page, copy its App Key. This key links the SDK to the correct app — keep it private.
Install the SDK with CocoaPods
From the project folder, open a Terminal window. If the project does not have a Podfile, run pod init. Open the Podfile and add the SDK inside your application's target:
target 'YourApp' do
use_frameworks!
pod 'AppAmbitSdk'
end
Save the file, return to Terminal, and run:
pod install
CocoaPods resolves the dependency and creates a workspace for the project. The terminal may show package warnings while the installation finishes — make sure the command completes and the workspace is generated.
Close the original Xcode project, then open the new .xcworkspace file. Inside the workspace, confirm that AppAmbitSdk appears under Pods.
Initialize AppAmbit
Open the SwiftUI application entry point. Import AppAmbit at the top of the file, add an initializer to the App structure, and call AppAmbit.start with the App Key you copied from the dashboard. Initialize the SDK only once during application startup.
import SwiftUI
import AppAmbitSdk
@main
struct YourApp: App {
init() {
AppAmbit.start(appKey: "your-app-key-here")
}
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
Run the application again. The app launches normally, and AppAmbit starts the first session. The dashboard now shows that the integration is active.
Trigger a Test Crash
Now add a temporary action that produces an uncaught crash. Open ContentView and replace the sample content with a test button. Inside the button, create an empty integer array and access an invalid index — this intentionally causes an index-out-of-range crash.
struct ContentView: View {
var body: some View {
Button("Trigger Test Crash") {
let numbers: [Int] = []
_ = numbers[1] // index out of range — testing only
}
}
}
This code is for testing only. Remove it before release.
Press Trigger Test Crash. The application terminates, and the simulator returns Home. Close the system crash report if it appears. Then reopen the application — this step is required for the report to be sent.
Verify the Crash Report
After the app launches again, return to the AppAmbit dashboard. Open Diagnostics. The report may take a few seconds to arrive — refresh the page if necessary. Once processed, the crash appears in the chart and diagnostics list.
Open the new crash to inspect its details. At the top, AppAmbit shows affected users, app version, occurrences, and last seen time. The message identifies the failure, while the stack trace shows where it occurred. Scroll through the trace to inspect application and system frames.
Further down, review the device, operating system, build, and session data. The charts also compare crashes by operating system and device. That's the complete crash-reporting flow with AppAmbit.
Next Steps
After completing this tutorial, check out:
Frequently Asked Questions
Q Which iOS setup does this tutorial use?
A clean SwiftUI application in Xcode, with the SDK installed via CocoaPods. The same crash-reporting flow applies to UIKit apps and other integration methods covered in the docs.
Q Why do I have to reopen the app after the crash?
Crash reports are captured when the app terminates and sent on the next launch. Reopening the application is what delivers the report to AppAmbit, so this step is required before the crash appears in the dashboard.
Q Where does the crash report show up?
In the AppAmbit dashboard under Diagnostics. Once processed, the crash appears in the chart and the diagnostics list. Open it to see affected users, app version, occurrences, last seen time, the failure message, and the full stack trace.
Q What details does a crash report include?
The top of the report shows affected users, app version, occurrences, and last seen time. Below that is the failure message and stack trace with application and system frames, followed by device, operating system, build, and session data. Charts compare crashes by operating system and device.
Q Is it safe to leave the test crash button in my app?
No. The test button and the index-out-of-range code are for verifying your integration only. Remove them before you ship — never release intentional crash code to production.
Q Do you offer a free account?
Yes — AppAmbit offers a free account with everything you need to get started. You can create apps, track crashes, send analytics, view logs, and upload builds. You only pay if your usage grows beyond the free tier limits.
Q How do I get support or migration help?
The AppAmbit team is available to help you set up crash reporting or migrate an existing project.
Ready to get started with AppAmbit?
Monitor your mobile apps with real-time crash reporting, analytics, and app distribution.
Start Free Trial