Skip to main content

Configuration

Swiftpatch reads configuration from three places, in precedence order:

  1. Props passed to <SwiftPatchProvider config={...}> in JavaScript (highest precedence).
  2. Native config — Info.plist on iOS, strings.xml on Android. Written by swiftpatch init.
  3. Defaults — sensible for 95% of apps.

You usually only need to touch the Provider config. Native values come from swiftpatch init.

The minimum config​

<SwiftPatchProvider config={{ debug: __DEV__ }}>
<App />
</SwiftPatchProvider>

That's it. deploymentKey is optional when swiftpatch init has written it to the native config.

SwiftPatchUserConfig — the three public options​

interface SwiftPatchUserConfig {
deploymentKey?: string;
debug?: boolean;
onUpdate?: (release: ReleaseInfo) => void;
}
OptionDefaultDescription
deploymentKeynullChannel-scoped read key. Omit if swiftpatch init embedded it in native config.
debugfalseEmits verbose SDK logs via console.log / native logcat / NSLog. Do not enable in production.
onUpdateundefinedCalled once per new release with the ReleaseInfo payload. Useful for triggering custom UI or analytics.

Advanced options (full SwiftPatchConfig)​

Expose these through the Provider's config prop. All are optional and internal-but-stable:

interface SwiftPatchConfig extends SwiftPatchUserConfig {
appId?: string;
serverUrl?: string;
checkOnResume?: boolean;
checkInterval?: number;
installMode?: InstallMode;
mandatoryInstallMode?: InstallMode;
customHeaders?: Record<string, string>;
publicKey?: string;
autoStabilizeAfterLaunches?: number;
crashDetectionWindowMs?: number;
maxCrashesBeforeRollback?: number;
autoStagingInDev?: boolean;
}
OptionDefaultDescription
appIdnullStable app identifier from the dashboard. When set, the SDK auto-resolves (and auto-rotates) the deployment key from the server.
serverUrlhttps://api.swiftpatch.io/api/v1Override the backend (self-hosted or staging).
checkOnResumetrueCheck for updates every time the app foregrounds.
checkInterval0Minimum ms between checks. 0 means check on every resume.
installModeON_NEXT_RESUMEWhen to apply a ready non-mandatory update. See install modes.
mandatoryInstallModeIMMEDIATEWhen to apply a ready mandatory update.
publicKeynull (reads from Info.plist / strings.xml)Override the Ed25519 verifier public key.
autoStabilizeAfterLaunches2Promote NEW slot to STABLE after N crash-free cold starts.
crashDetectionWindowMs10_000How long after launch a crash counts against the freshly-applied bundle.
maxCrashesBeforeRollback2Number of crashes before auto-rollback triggers.
autoStagingInDevfalseForce the STAGE environment when __DEV__ is true.

Install modes​

enum InstallMode {
IMMEDIATE = 'immediate', // Restart now
ON_NEXT_RESTART = 'onNextRestart', // Apply on next cold start
ON_NEXT_RESUME = 'onNextResume', // Apply when app foregrounds
}

Defaults are tuned for UX:

  • Non-mandatory updates use ON_NEXT_RESUME — the user sees the update the next time they come back.
  • Mandatory updates use IMMEDIATE — restart the moment the download finishes.

Native config​

swiftpatch init writes these into your native files automatically.

iOS — Info.plist​

<key>SwiftPatchDeploymentKey</key>
<string>dep_xxx...</string>

<key>BGTaskSchedulerPermittedIdentifiers</key>
<array>
<string>com.swiftpatch.bg-refresh</string>
</array>

<key>UIBackgroundModes</key>
<array>
<string>fetch</string>
<string>processing</string>
</array>

Optional extras:

KeyPurpose
SwiftPatchProjectIdProject ID. Optional.
SwiftPatchServerUrlCustom API endpoint.
SwiftPatchPublicKeyPublic key for signature verification.
SwiftPatchAppIdStable app id for key auto-resolution.

Android — strings.xml​

<resources>
<string name="swiftpatch_deployment_key">dep_xxx...</string>

<!-- Optional -->
<string name="SwiftPatchProjectId">proj_xxx</string>
<string name="SwiftPatchServerUrl">https://api.swiftpatch.io/api/v1</string>
<string name="SwiftPatchPublicKey">...</string>
</resources>

.swiftpatchrc​

Per-project config for the CLI. Commit this file — it does not contain secrets.

.swiftpatchrc
{
"appId": "app_abc123",
"app": "my-app",
"platform": "ios",
"signingKey": "./.swiftpatch/keys/private.pem"
}
FieldDescription
appIdStable app id from the dashboard.
appApp slug for human-friendly logs.
platformios | android — default platform for swiftpatch deploy.
signingKeyPath to the Ed25519 private key.
Keep the private key out of Git

.swiftpatch/ is added to .gitignore by swiftpatch init. Never commit private.pem. For CI, store the key as an encrypted secret — see CI/CD.

Verifying the native config​

import { getNativeConfig } from '@swiftpatch/react-native';

const cfg = await getNativeConfig();
// {
// projectId: string | null,
// appToken: string | null,
// appId: string | null,
// deploymentKey: string | null,
// serverUrl: string | null,
// publicKey: string | null,
// }

Use this in a useEffect to verify swiftpatch init ran correctly.

Next steps​

Architecture​

The SDK is a state machine. Each transition maps to a public method or an internal verification step — and every failure path returns to Idle without touching the running bundle.