Rollbacks
When a bad bundle ships, SwiftPatch reverts your app to the last stable version -- automatically or on demand -- before most users notice.
Think of it like an undo button for your deployments.
Manual rollbacks from the dashboard, CLI, or API take effect on the server immediately. Devices pick up the change on their next update check, typically within seconds.
Automatic Rollbacks
The SDK monitors app health after every OTA update. If the new bundle crashes repeatedly before stabilization, SwiftPatch reverts automatically. No human intervention needed.
See Crash Detection for the full monitoring pipeline.
How It Works
Step 1: OTA update installs and the app restarts with the new bundle.
Step 2: The native module opens a crash detection window (default: 10 seconds).
Step 3: withSwiftPatch calls markMounted() when your React tree renders.
Step 4: If the app crashes before markMounted(), the SDK increments a crash counter.
Step 5: After reaching the threshold (default: 2 crashes), the SDK reverts to the previous stable bundle.
Step 6: A ROLLBACK_PROD event is reported to the API.
Configuration
export default withSwiftPatch(App, {
crashDetectionWindowMs: 10000, // 10s window (default)
maxCrashesBeforeRollback: 2, // 2 crashes trigger rollback (default)
});
| Option | Default | Description |
|---|---|---|
crashDetectionWindowMs | 10000 | Time window after launch for crash detection |
maxCrashesBeforeRollback | 2 | Consecutive crashes before rollback |
- Most apps: keep the default of 2
- Flaky native modules: set to 3
- Mission-critical apps: set to 1 with a longer window (15-20s)
Manual markMounted
If you use useSwiftPatch directly instead of withSwiftPatch, call markMounted() yourself:
import { useSwiftPatch } from '@swiftpatch/react-native';
function App() {
const { markMounted } = useSwiftPatch();
useEffect(() => {
markMounted();
}, []);
return <YourApp />;
}
Manual Rollbacks
Use manual rollbacks for issues that crash detection does not catch -- data corruption, broken API calls, or compliance problems.
From the Dashboard
Step 1: Go to Releases.
Step 2: Find the release.
Step 3: Click Rollback and confirm.
From the CLI
# Roll back the latest release
swiftpatch rollback -a <app-id> -p ios
# Roll back a specific release
swiftpatch releases rollback <release-id> -a <app-id>
From the API
curl -X POST https://api.swiftpatch.io/v1/orgs/:orgId/apps/:appId/releases/:releaseId/rollback \
-H "Authorization: Bearer <token>"
From the SDK
import { useSwiftPatch } from '@swiftpatch/react-native';
function Settings() {
const { rollback } = useSwiftPatch();
return (
<Button
title="Roll Back Update"
onPress={async () => {
await rollback();
}}
/>
);
}
Rollback Behavior
Here is what happens when you roll back:
- Server-side: The release is marked as rolled back and stops serving
- Devices that have not installed it: Skip it entirely on the next check
- Devices that already installed it: On the next check, the SDK detects the rollback and reverts to the previous stable bundle
- Analytics: Rollback metrics are recorded in your dashboard
Security Note
If you use bundle signing and your private key is compromised, rollback alone is not enough. You must rotate your key pair immediately. See the Key Rotation guide.
Next Steps
- Crash Detection -- The monitoring pipeline behind automatic rollbacks
- Bundle Signing -- Cryptographic verification for updates
- Rollouts -- Combine gradual rollouts with rollbacks for maximum safety