Modern-Apps.git
Publicgit clone https://git.maproj.org/Modern-Apps.gitModern-Apps.git / apple / XCFramework / IOS_ACTUALS_NOTES.md
| 1 | # iOS platform actuals — implementation notes for the Mac (Kotlin side) |
| 2 | |
| 3 | The live actuals land in `library/everysync-core/src/iosMain/` on the Mac |
| 4 | (needs the Apple SDK — cannot compile on this Windows box). The current |
| 5 | `iosMain` stubs (`CryptoIos.kt`, `IosRelayTransport.kt`, `HmacIos.kt`) throw |
| 6 | `UnsupportedOperationException` until Phase 3; this doc specifies exactly what |
| 7 | replaces each throw, so the Mac work is mechanical. **Do NOT modify the core:** |
| 8 | `commonMain` contracts are frozen — only `iosMain` actuals change. |
| 9 | |
| 10 | ## `expect` -> `actual` map |
| 11 | |
| 12 | | `commonMain` expect / interface | `iosMain` actual | Backing API | |
| 13 | |---|---|---| |
| 14 | | `crypto.CryptoKt.AesGcm` | `CryptoIos.kt` (`actual object AesGcm`) | CryptoKit `AES.GCM` via the `everysync_aes_gcm_encrypt/decrypt` C bridge in `../Shared/EverysyncCoreCrypto.swift` (bound through the SAME cinterop module as the 10 PQC fns — see `e2eePqc.def` + `e2ee_pqc.reference.h`). Layout `[12B nonce][ct][16B tag]` == JCE layout. `newContentKey()` = 32B from `PlatformRandom`. Fills the Rust AES gap — no AES added to Rust. | |
| 15 | | `crypto.CryptoKt.PlatformRandom` | `CryptoIos.kt` (`actual object PlatformRandom`) | `SecRandomCopyBytes(kSecRandomDefault, …)` via cinterop (platform Security framework). | |
| 16 | | `passwords.TotpKt.HmacSha1` | `passwords/HmacIos.kt` (`actual object HmacSha1`) | CryptoKit `HMAC<Insecure.SHA1>` (pure framing stays in `Totp`: base32 RFC 4648, 30s step, big-endian counter, dynamic truncation). | |
| 17 | | `network.PqcCrypto` (interface, not expect) | New `iosMain/.../network/PqcIos.kt` | The 10 bound cinterop fns (`e2ee.pqc.native.*`): `generateKem` = `pqc_kem_keygen`; `generateDsa` = `pqc_dsa_keygen`; `bundle` = `pqc_bundle_build`; `splitBundle` = `pqc_bundle_split` (null on parse failure); `seal` = encaps + `BundleFraming.prefix(encap, aes)` where `aes` = CryptoKit AES-GCM under `SHA256(BE32(1)‖rawSS)` (identical KDF to Kotlin `concat_kdf` — see `c_bridge.rs` comment); `decrypt` = split + decaps + AES open; `sign` = `pqc_dsa_sign`; `verify` = `pqc_dsa_verify` (false on 0 AND -1). Copy-then-`pqc_free`; zero priv/SS via `pqc_secure_zero`. | |
| 18 | | `network.RelayTransport` (interface) | `network/IosRelayTransport.kt` (exists as stub) | Ktor-Darwin engine + sec-trust pinning from the common-resource DERs (`src/commonMain/resources/ca/` via `syncCaResources`). Envelope codec (`appendRecords`/`pullRecords`), channel names, and null-on-failure live in `SharedRelayTransport` — the actual only supplies `RelayHttpClient.post/subscribe`. | |
| 19 | | `platform.PlatformKt.SecureStore` (interface) | New `iosMain/.../platform/SecureStoreIos.kt` | Keychain `kSecClassGenericPassword` per `../Shared/KeychainSecureStore.swift` (service `com.vayunmathur.everysync.securestore`, shared access group, `AfterFirstUnlockThisDeviceOnly`; longs big-endian Int64; `onlyIfAbsent` under a mutex). | |
| 20 | | `platform.PlatformKt.SyncScheduler` (interface) | New `iosMain/.../platform/SyncSchedulerIos.kt` | `BGTaskScheduler.submit/cancel` for the five identifiers in `../Shared/BackgroundSync.swift` (refresh intervals from `schedulePeriodic`; `syncNow` = `scheduleProcessing`). Scheduling only — cycles run in `SyncDriver`. | |
| 21 | | `platform.PlatformKt.SyncSink` (interface) | Kotlin shims per type (new `iosMain/.../sinks/`) | `RelayStore` shims over the envelope IPC SQLite files (SAME schema as `../Shared/EnvelopeIPC.swift` — SQLDelight or direct sqlite via cinterop; WAL + `busy_timeout=5000`). Table map + baseline sidecar: see `../Hub/IPCRelayStore.swift`. | |
| 22 | |
| 23 | ## Slices to run on the Mac (scoped, never whole-repo) |
| 24 | |
| 25 | ```sh |
| 26 | ./gradlew :library:everysync-core:compileKotlinIosArm64 \ |
| 27 | :library:everysync-core:compileKotlinIosSimulatorArm64 |
| 28 | ./gradlew :library:everysync-core:lint |
| 29 | ./gradlew :library:everysync-core:checkMetadata |
| 30 | xcodebuild -project apple/EverySync.xcodeproj -scheme Passwords \ |
| 31 | -destination 'platform=iOS Simulator,name=iPhone 16' build |
| 32 | xcodebuild -project apple/EverySync.xcodeproj -scheme Notes \ |
| 33 | -destination 'platform=iOS Simulator,name=iPhone 16' build |
| 34 | xcodebuild -project apple/EverySync.xcodeproj -scheme Hub \ |
| 35 | -destination 'platform=iOS Simulator,name=iPhone 16' build |
| 36 | ``` |
| 37 | |
| 38 | (The Xcode project itself is created on the Mac — no `.xcodeproj` is |
| 39 | checked in from here. Reference plists/entitlements live next to each |
| 40 | target: `Passwords/`, `Notes/`, `Hub/`.) |