Flutter iOS Specifics
On iOS, Apple's XNU kernel security policies prohibit dynamic loading and execution of unsigned executable memory pages (MAP_JIT restrictions). To enable instant over-the-air hot updates while maintaining strict App Store compliance, the Shorebird/TkushPatch iOS engine uses a hybrid AOT + interpreter architecture (patch artifact).
1. iOS Architecture: App.framework, diff_base, and patch artifact
- Base Release: Compiles the IPA with
tk-ota-push release -p iosand submits to TestFlight or App Store. - Patch Creation: Compiles code changes with
tk-ota-push patch -p ios. - Activation: Flutter runtime verifies the digital signature and loads updated code on app launch.
What Happens During tk-ota-push release -p ios (Publisher.releaseIos)
- The CLI compiles the application in release mode (
flutter build ios --releaseorflutter build ipa --releaseif--artifact ipa). - It deterministically resolves the
Runner.appbundle (inbuild/ios/archive/Runner.xcarchivefor an IPA orbuild/ios/iphoneos/for a standard build) and verifiesFrameworks/App.framework/App. - It saves a baseline reference copy in
.ota_ios_release_cache/<version>/:Runner.app(intact signed bundle)App(Mach-O baseline AOT binary)supplement/(linking table files:App.*.link,App.*_table.json,App.dd_resolution.tsv)
- It runs
aot_tools dump_blobswithanalyze_snapshot_arm64onAppto extractdiff_base(Dart snapshot blobs), and sealsdiff_baseon the OTA server.
What Happens During tk-ota-push patch -p ios (Publisher.patchIos)
- Anti-Crash Cache Hash Verification: the CLI computes the SHA-256 of
.ota_ios_release_cache/<version>/diff_baseand compares it to thebaseSha256Hashlocked on the server. On divergence (iOS HASH MISMATCH), execution aborts immediately to protect against runtime crashes (Segfault) on iOS devices. - Dart Kernel Compilation (
app.dill): runsflutter build ios --release --no-codesign. - ELF Snapshot Generation (
out.aot): executesgen_snapshot_arm64with--deterministic --snapshot-kind=app-aot-elfand aligned DWARF flags (--dwarf-stack-traces,--resolve-dwarf-paths,--save-debugging-info=...,--strip). - Linking (
aot_tools link): links the baselineAppbinary and the newout.aotsnapshot intopatch artifact. Unchanged Dart functions continue to execute at full native speed on ARM64 hardware, while modified or newly introduced Dart functions are executed by the embedded interpreter. - Signed Bundle Restoration: restores
.ota_ios_release_cache/<version>/Runner.appintobuild/ios/iphoneos/Runner.app(since--no-codesignhad stripped codesigning).
.ota_ios_release_cache/<version>On iOS, aot_tools link requires the baseline Mach-O App binary and accompanying supplement/ files to generate valid dispatch tables for patch artifact. Preserve or archive the .ota_ios_release_cache/<version>/ folder in CI/CD throughout the production lifecycle of that release.
2. iOS Artifact Formats (.ipa vs .app) and Export Methods
The CLI supports direct generation of signed .ipa archives via --artifact ipa, --export-method, and --export-options-plist:
| CLI Flag | Supported Values | Usage |
|---|---|---|
--artifact ipa | ipa (or default ios) | Runs flutter build ipa --release and extracts Runner.app from build/ios/archive/Runner.xcarchive. |
--export-method | app-store, ad-hoc, enterprise, development | Forwards --export-method=<method> to flutter build ipa. |
--export-options-plist | Path to .plist file | Forwards --export-options-plist=<path> to flutter build ipa for custom Xcode export options. |
iOS Command Examples
# iOS Release targeted for TestFlight / App Store Connect
tk-ota-push release -p ios --artifact ipa --export-method app-store
# iOS Ad-Hoc Release for internal distribution to registered test iPhones (UDID)
tk-ota-push release -p ios --artifact ipa --export-method ad-hoc
# Publishing an iOS patch to the active Release
tk-ota-push patch -p ios -m "Fix biometric verification issue"
3. iOS Native Integrity Safeguard (NativeIntegrityScanner.scanIosApp)
Just as on Android, an iOS OTA patch cannot modify Swift/Objective-C native code or Apple-signed system frameworks.
NativeIntegrityScanner.scanIosApp(Directory appDir) (lib/src/cli/native_integrity.dart) computes a deterministic SHA-256 fingerprint over:
Info.plist- The main Mach-O executable binary located at the root of
Runner.app - All files located under
Frameworks/, strictly excludingFrameworks/App.framework(which contains Dart code).
If a modification to Info.plist, a CocoaPod framework, or Swift native code is detected during patch, the CLI aborts and instructs you to publish a new Store Release.
4. Apple Compliance (App Store Review Guidelines)
TkushPatch's iOS design aligns with Apple App Store Review Guidelines:
- No executable Mach-O code is downloaded or mapped with
PROT_EXECpost-installation. - Unchanged functions execute native machine instructions signed by Apple in
App.framework/Appduring initial App Store submission. - Modified functions in
patch artifactare executed strictly by the interpreted virtual machine within the C++ Flutter engine, without JIT compilation. - All patches are signed via digital signature and validated by the Rust engine (
patch_verification: strict).