Pure Continuous Native Generation Without Checked-In Native Trees#
Keeping an Expo mobile repository clean and reproducible means keeping android/ and ios/ out of source control while still verifying full native builds on every change. In Phase 4 of SpeakOn, we built the standalone open-source mobile client (Celio1878/speakon-mobile, com.aldeon.speakon) on Expo SDK 57, Expo Router, and strict TypeScript.
Every commit stays pure Continuous Native Generation (CNG), while CI validates npx expo prebuild --clean for both Android and iOS and local Linux verification compiles the full native Android debug APK before discarding generated folders.
Local Network Plugin & Native Build Gotchas#
Three concrete tooling constraints shaped how the native build works cleanly under Bun and @expo/config:
- CommonJS Local Config Plugin (
plugins/withLocalNetwork.js+.d.ts):@expo/configtranspilesapp.config.tsdirectly, but delegates nestedrequire("./plugins/...")calls to Node without a TypeScript loader. ExportingwithLocalNetworkfrom CommonJSplugins/withLocalNetwork.jsalongside a companion.d.tsdeclaration satisfies stricttsc --noEmit,bun test, and Expo Prebuild simultaneously—injectingandroid:usesCleartextTraffic="true"on Android andNSAllowsLocalNetworking,_http._tcpBonjour discovery, plus camera/microphone privacy prompts on iOS. - Skia Prebuilt Binaries Under Bun (
trustedDependencies): Bun blocks dependencypostinstalllifecycle scripts by default, which skipped@shopify/react-native-skia'sscripts/install-libs.jsand caused Android CMake to fail looking forlibskia.a. Adding"@shopify/react-native-skia"totrustedDependenciesinpackage.jsonrestored the24 MBarm64-v8a/libskia.abinary cleanly and keptbun install --frozen-lockfilepassing with zero untrusted packages. - Architecture & Gradle Tuning:
expo-build-propertiespins Android ABIs to["arm64-v8a", "x86_64"]and setsorg.gradle.workers.max=4so Linux local builds finish cleanly without memory thrashing.
Offline-First expo-sqlite Architecture & Testability#
Importing expo-sqlite directly in shared TypeScript files pulls in react-native/index.js, whose Flow import typeof * syntax cannot be parsed directly by bun test. Instead of heavy bundler mocks, we split persistence cleanly:
src/storage/offlineCache.ts: Contains pure SQLite WAL schema initialization and CRUD queries (cached_profile,cached_sessions,cached_turns,cached_analytics,sync_meta) parameterized over a minimalSqliteDriverinterface.src/storage/sqliteCache.ts&src/__tests__/sqliteCache.test.ts: Production screens bindexpo-sqlite, while unit tests bindbun:sqlitedirectly against real SQLite WAL tables andON DELETE CASCADEconstraints.src/storage/secureStore.ts: Keeps desktop URLs,access_token/refresh_token, and single-use pairing credentials (X-SpeakOn-Device) strictly inside encryptedexpo-secure-store.
LAN QR / USB Pairing, Passwordless Auth & Voice Transport#
- Flexible Desktop Pairing (
app/pair.tsx&src/lib/serverUrl.ts): Supports camera QR scanning (speakon://pair?u=http://<lan-ip>:8000&c=<code>), manual RFC1918 LAN URLs, and USBadb reverse tcp:8000 tcp:8000loopback (http://127.0.0.1:8000), while rejecting cleartext public hosts./healthprobes report round-trip latency and discover active providers cleanly. - Passwordless Authentication (
app/login.tsx): Supports 6-digit Email OTP always and reveals Sign in with Apple / Sign in with Google only when enabled by both build capabilities and desktop/api/auth/providers, with zero password inputs anywhere in source. - Dual Voice Pipeline (
src/audio/voiceTransport.ts): Combinesexpo-audio.m4aPush-to-Talk uploads (POST /api/sessions/{id}/turn),@siteed/audio-studio16 kHz mono PCM16 WebSocket streaming with{ type: "cancel" }barge-in, speaker/earpiece routing (shouldRouteThroughEarpiece), tone-colored Pinyin toggles, and bottom sheets for grammar corrections and pronunciation breakdown.
Verification, Native APK Compilation, and CI#
- Strict Types & Unit Tests:
tsc --noEmitreported 0 errors,bun testpassed 11 / 11 tests (77 assertions) across URL normalization, i18n EN/PT key parity, Pinyin tone parsing, source security checks, Expo plugin transforms, and real SQLite WAL persistence. - Expo Prebuild & Android APK Build: Both
npx expo prebuild --platform ios --no-install --cleanandnpx expo prebuild --platform android --no-install --cleansucceeded cleanly;./android/gradlew -p android assembleDebugexecuted 754 tasks cleanly in 8 minutes, producing a 189 MB nativeapp-debug.apkbefore cleaning generated directories. - Live Pairing E2E & Public CI: Verified live Mailpit OTP login,
parsePairingUri()QR parsing,/api/pairing/claim,X-SpeakOn-Deviceauthenticated calls to/api/sessionsand/api/analytics/streak, and refresh token rotation againstspeakon-services. On GitHub (Celio1878/speakon-mobiledevelop), Gitleaks Secret Scan (47442115455) and CI (47442115428) both passed with zero secrets leaked.
Next up in Phase 5: building the Mandarin Studio backend inside speakon/services/app/mandarin/ with checksummed datasets, bilingual Foundations curriculum, jieba/pypinyin/OpenCC, AI dissectors/coaches, FSRS scheduling, and signed offline SQLite packs.
