Quickstart
iOSparkle adds over-the-air (OTA) self-updates to the development builds of an iOS or iPadOS app. The library never reaches the App Store build: only a development variant links it, every use sits behind an explicit compilation condition, and the App Store Audit proves the shipping archive contains zero residue.
The whole integration is five steps:
- Choose an isolation pattern
- Gate every use with
#if IOSPARKLE_ENABLED - Wire three lines of code
- Publish the first build to a Channel
- Run the App Store Audit
What you need
Xcode 16 or later. The package uses
swift-tools-version: 6.0and supports iOS 16.0 and later.An Apple Developer team and a device you can run on from Xcode. OTA installation needs a Development or Ad Hoc profile that lists the device, so App Store signing cannot be used for the builds you publish.
An HTTPS location that can serve four static files. Any static host works; see Self-Hosting & Private Channels.
The
iosparklecommand-line tool (macOS 13 or later). Until a release binary is published, build it from a checkout of this repository:swift build -c release --package-path cli # binary: cli/.build/release/iosparkle
Throughout this chapter the shipping app is MyApp (com.example.myapp), the development app is MyAppDev (com.example.myapp.dev), and the Channel lives at https://ota.example.com/my-app-dev/.
1. Choose an isolation pattern
Both patterns keep iOSparkle out of MyApp entirely. Pick one.
Dual-Target Isolation (recommended)
Two app targets share one set of sources. Only the development target declares the iOSparkle package dependency.
MyApp (ships to the App Store) | MyAppDev (receives OTA updates) | |
|---|---|---|
| Sources | shared | shared |
| Bundle identifier | com.example.myapp | com.example.myapp.dev |
iOSparkle package dependency | none | linked |
SWIFT_ACTIVE_COMPILATION_CONDITIONS (Debug and Release) | (unchanged) | $(inherited) IOSPARKLE_ENABLED |
To set it up in Xcode:
- Select the
MyApptarget and choose Edit ▸ Duplicate, then Duplicate Only. Rename the copy toMyAppDevand change its bundle identifier tocom.example.myapp.dev. - Choose File ▸ Add Package Dependencies…, add the
iOSparklepackage (https://github.com/justinyanme/iOSparkle.git), and under Add to Target selectMyAppDevonly. - In the build settings of
MyAppDev, set Swift Active Compilation Conditions to$(inherited) IOSPARKLE_ENABLEDfor bothDebugandRelease. LeaveMyAppuntouched.
MyAppDev is a normal app target: give it its own icon and display name so both apps are distinguishable on a device.
Single-Target Multi-Configuration
When a second target is not an option, keep one target and add a configuration for OTA builds.
- In the project editor, select the project, then Info ▸ Configurations. Duplicate
Releaseand name the copyDevOTA. It inherits-OfromRelease. - Add the
iOSparklepackage dependency to the target. - Set these build settings on the target:
| Setting | Debug | DevOTA | Release |
|---|---|---|---|
SWIFT_ACTIVE_COMPILATION_CONDITIONS | $(inherited) DEBUG IOSPARKLE_ENABLED | IOSPARKLE_ENABLED | (must not contain IOSPARKLE_ENABLED) |
PRODUCT_BUNDLE_IDENTIFIER | com.example.myapp.dev | com.example.myapp.dev | com.example.myapp |
EXCLUDED_SOURCE_FILE_NAMES | — | — | iOSparkle.o |
In Xcode's conditional notation:
SWIFT_ACTIVE_COMPILATION_CONDITIONS[config=Debug] = $(inherited) DEBUG IOSPARKLE_ENABLED
SWIFT_ACTIVE_COMPILATION_CONDITIONS[config=DevOTA] = IOSPARKLE_ENABLED
PRODUCT_BUNDLE_IDENTIFIER[config=Debug] = com.example.myapp.dev
PRODUCT_BUNDLE_IDENTIFIER[config=DevOTA] = com.example.myapp.dev
EXCLUDED_SOURCE_FILE_NAMES[config=Release] = iOSparkle.o
Debug links iOSparkle too, so it takes the .dev identifier as well: with the App Store identifier it would fetch a Feed whose bundleId it can never match, and it would clash with the App Store build on a device.
Release still sees the package dependency, so the iOSparkle module is compiled, but the whole library is one SwiftPM target that Xcode compiles to a single object file, iOSparkle.o. Excluding that one file from Release leaves nothing to link and nothing to embed. The App Store Audit in step 5 verifies this on every archive.
Why a separate .dev bundle identifier
iOS refuses to install an OTA package over an app with the same bundle identifier unless the installed app was itself installed with a provisioning profile. An App Store or TestFlight build was not, so with one shared identifier:
- A tester who has the App Store build must delete it, losing all local data, before the OTA build can install.
- The App Store build and the OTA build can never coexist on one device.
With com.example.myapp.dev, both apps sit side by side, and each OTA update replaces the previous OTA build in place, keeping the app container. Use the .dev identifier for every configuration that links iOSparkle.
2. The red line: #if IOSPARKLE_ENABLED
Every import iOSparkle and every use of its types goes inside the explicit condition:
#if IOSPARKLE_ENABLED
import iOSparkle
#endif
The condition must be one you define yourself, only for the development variant: IOSPARKLE_ENABLED, or a development flag your project already has.
Never gate iOSparkle with a bare #if canImport(iOSparkle). Xcode adds the build products directory to the module search path of every target that shares it. After any build of MyAppDev, iOSparkle.swiftmodule is still there, so MyApp — which does not link iOSparkle.o — evaluates canImport(iOSparkle) as true:
- In
Debug,MyAppfails to link withUndefined symbols. - In
Release(-O, whole-module optimization), the compiler reads the serialized SIL of that stale module and inlines iOSparkle code across the module boundary, including theitms-services://?action=download-manifest&url=literal, straight into the shipping binary. Depending on what the gated code touches, you get a link error or, worse, a build that exits0without a single warning and ships App Store residue that only the App Store Audit catches.
An explicit condition cannot misfire this way: it is defined by the build settings of the development variant alone.
3. Wire it up
Three lines do the work. IOSparkleUpdater is @MainActor-isolated, so create it in a main-actor type: a SwiftUI App or View, a UIResponder subclass such as a scene delegate, or a type you mark @MainActor yourself.
SwiftUI
import SwiftUI
#if IOSPARKLE_ENABLED
import iOSparkle
@MainActor
enum Updates {
static let updater = IOSparkleUpdater(channelURL: URL(string: "https://ota.example.com/my-app-dev")!) // 1
}
#endif
@main
struct MyAppDevApp: App {
var body: some Scene {
WindowGroup {
ContentView()
#if IOSPARKLE_ENABLED
.iOSparkleUpdater(Updates.updater) // 2: starts automatic checks when the view appears
#endif
}
}
}
struct SettingsView: View {
var body: some View {
Form {
#if IOSPARKLE_ENABLED
IOSparkleDebugSection(updater: Updates.updater) // 3: status, Update / Reinstall, diagnostics
#endif
}
}
}
.iOSparkleUpdater(_:) calls startAutomaticChecks() when the view appears; from then on the updater observes scene activation itself. IOSparkleDebugSection is a Section for a Form or List and pushes its detail screen through a NavigationStack.
UIKit
import UIKit
#if IOSPARKLE_ENABLED
import iOSparkle
@MainActor
enum Updates {
static let updater = IOSparkleUpdater(channelURL: URL(string: "https://ota.example.com/my-app-dev")!) // 1
}
#endif
final class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options: UIScene.ConnectionOptions) {
guard let windowScene = scene as? UIWindowScene else { return }
let window = UIWindow(windowScene: windowScene)
window.rootViewController = UINavigationController(rootViewController: SettingsViewController())
self.window = window
window.makeKeyAndVisible()
#if IOSPARKLE_ENABLED
Updates.updater.startAutomaticChecks() // 2
#endif
}
}
final class SettingsViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
title = "Settings"
navigationItem.rightBarButtonItem = UIBarButtonItem(
title: "Developer Updates", style: .plain, target: self, action: #selector(showDeveloperUpdates)
)
}
@objc private func showDeveloperUpdates() {
#if IOSPARKLE_ENABLED
navigationController?.pushViewController( // 3: push inside a navigation controller
IOSparkleDebugViewController(updater: Updates.updater), animated: true)
#endif
}
}
With that, a device running the MyAppDev Release build checks the Channel every time it comes to the foreground (at most once every 30 seconds), shows a system alert when a newer build is available, and installs it after the user taps Update. The Developer Updates screen shows the installed and published builds and offers Check Now, Update, and Reinstall.
To see it working on a device you run from Xcode, open Developer Updates and tap Check Now. Automatic alerts are deliberately off in Debug builds; Troubleshooting explains every case where the updater stays silent on purpose.
The Host App SDK & Headless API chapter covers configuration (private Channel headers, a busy flag, an exit hook) and replacing the built-in alert with your own UI.
4. Publish the first build
Publish builds that were archived from MyAppDev with the Release configuration (or DevOTA in the single-target setup). A -O build installed from the Channel is the variant the updater treats as production: automatic checks are on.
Reserve the build number, then build with it.
CHANNEL=https://ota.example.com/my-app-dev BUILD=$(iosparkle next-build --channel-url "$CHANNEL") # 1 for a new Channelxcodebuild -project MyApp.xcodeproj -scheme MyAppDev -configuration Release \ -derivedDataPath build/DerivedData -archivePath build/MyAppDev.xcarchive \ archive CURRENT_PROJECT_VERSION="$BUILD"Export an IPA signed for development.
ExportOptions.plist:<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>method</key> <string>development</string> <key>signingStyle</key> <string>automatic</string> <key>teamID</key> <string>YOURTEAMID</string> </dict> </plist>xcodebuild -archivePath build/MyAppDev.xcarchive -exportPath build/MyAppDev \ -exportOptionsPlist ExportOptions.plist exportArchiveUse
release-testingas the method for an Ad Hoc export. An App Store export has no device list and cannot be installed over the air;iosparkle publishrejects it.Publish. Everything is generated on your Mac; the destination only stores files.
iosparkle publish --ipa build/MyAppDev/MyAppDev.ipa --channel-url "$CHANNEL" \ --out ./channel --commit "$GIT_COMMIT" --notes-file notes.txtUpload
./channelto the Channel location, or letpublishdo it over SSH with--ssh deploy@ota.example.com:/var/www/ota/my-app-devinstead of--out.Verify end to end.
iosparkle verify --channel-url "$CHANNEL" --ipa build/MyAppDev/MyAppDev.ipaInstall once on a device by opening
https://ota.example.com/my-app-dev/in Safari and tapping Install. Every later update arrives through the app.
The Channel directory, the Feed file, and the install manifest are specified in Static Feed & Channel Spec; every command and flag is in CLI & App Store Audit.
5. Run the App Store Audit (mandatory)
The integration is done only when the shipping archive passes the App Store Audit. Archive MyAppDev first and MyApp afterwards in the same DerivedData, and make both archives share one products directory. Xcode normally gives each archive its own, which would hide the iOSparkle.swiftmodule that MyAppDev leaves behind; with a shared directory, MyApp compiles right beside it — the situation in which a bare canImport misfires — and the audit still runs on a real archive, stripped and with its dSYMs. This is the same gate the repository's own CI runs.
DD="$(pwd)/build/DerivedData" # absolute: package build steps run from the package's own directory
PRODUCTS="$DD/Build/Products/iphoneos" # one products directory for both archives
archive() {
xcodebuild -quiet -project MyApp.xcodeproj -scheme "$1" -configuration "$2" \
-destination 'generic/platform=iOS' -derivedDataPath "$DD" -archivePath "build/$1-$2.xcarchive" \
CONFIGURATION_BUILD_DIR="$PRODUCTS" \
'DWARF_DSYM_FOLDER_PATH=$(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)' \
CODE_SIGNING_ALLOWED=NO archive
}
rm -rf build/*.xcarchive # never audit a stale artifact
archive MyAppDev Release # leaves iOSparkle.swiftmodule in $PRODUCTS
archive MyApp Release # must build, and stay clean, beside it
iosparkle audit-appstore build/MyApp-Release.xcarchive && echo "zero residue"
Both archives must exit 0 before anything is audited: a failed link step leaves an incomplete .app behind, and an audit of that leftover passes for the wrong reason. CODE_SIGNING_ALLOWED=NO skips signing, which the audit does not need. The DWARF_DSYM_FOLDER_PATH line keeps each archive's dSYMs where Xcode collects them, so audit the .xcarchive rather than an exported .ipa and the symbol check runs too. In the single-target setup, archive the one scheme with archive MyApp DevOTA first.
As a sanity check that the audit is not blind, run it on the development archive as well: iosparkle audit-appstore build/MyAppDev-Release.xcarchive must fail.
Repeat this gate on every change to targets, configurations, or package dependencies. The CLI & App Store Audit chapter describes the five checks, and a ready-made workflow for coding agents is in skills/iosparkle-integrate.