Testing Updates
Before you ship an OTA update to production, test it end-to-end in a development environment. This guide walks you through the process.
Step 1: Enable Debug Mode
Turn on verbose logging so you can see exactly what the SDK is doing:
export default withSwiftPatch(App, {
debug: true,
});
Step 2: Build a Release Version
You need a release build -- debug builds use Metro bundler and skip SwiftPatch entirely.
# iOS
npx react-native run-ios --mode Release
# Android
npx react-native run-android --mode release
Step 3: Deploy a Test Update
swiftpatch deploy -p ios --hermes -n "Test update"
Step 4: Verify
- Open the app
- The SDK detects and downloads the update
- Restart to apply
- Confirm your changes are visible
Watch the console logs for [SwiftPatch] entries to follow the update lifecycle in real time.
Testing Scenarios
Rollback
Step 1: Deploy an update that crashes on launch.
Step 2: Open the app -- it crashes.
Step 3: Open again -- the SDK rolls back automatically.
Step 4: Verify the app runs on the previous version.
Step 5: Check the dashboard for a ROLLBACK_PROD event.
Mandatory Updates
Step 1: Deploy with --mandatory:
swiftpatch deploy -p ios --hermes --mandatory
Step 2: Verify availableUpdate.isMandatory is true.
Step 3: If using InstallMode.IMMEDIATE, the app restarts automatically.
Offline Behavior
Step 1: Install the app with network connectivity.
Step 2: Disable network.
Step 3: Verify the app works with the current bundle.
Step 4: Re-enable network and verify update checking resumes.
Differential Patches
Step 1: Deploy an initial update (the first one is always a full download).
Step 2: Make a small change and deploy again.
Step 3: Check availableUpdate.isPatch -- it should be true.
Step 4: Verify the download size is much smaller than the full bundle.
Debug Logging
Check the native logs for detailed SDK output:
# iOS
xcrun simctl spawn booted log show --predicate 'subsystem == "com.swiftpatch"' --last 5m
# Android
adb logcat -s SwiftPatch
Expected log output:
[SwiftPatch] Checking for updates...
[SwiftPatch] Update available: v1.2.0
[SwiftPatch] Downloading patch: 204800 bytes
[SwiftPatch] Download complete
[SwiftPatch] Bundle hash verified
[SwiftPatch] Update installed, restart required