App Capacitor Builder
When to use
Targets android and ios. Capacitor 8 is the imposed mobile engine; never switch to React Native, Flutter or Tauri Mobile.
Inputs
os/<target>scaffold, frontend dist (webDir), app name, app id, package manager.
Procedure (run inside os/<target>)
appfactory action=scaffold target=<id>.npm install @capacitor/coreandnpm install -D @capacitor/cli(pnpm:pnpm add, yarn:yarn add, bun:bun add).npx cap init "<name>" <app_id> --web-dir <rel path to dist>(skip whencapacitor.config.tsexists).- Android:
npm install @capacitor/android,npx cap add android. iOS (macOS only):npm install @capacitor/ios,npx cap add ios. - Build the web:
npm run build(site script oros/<target>/web), thennpx cap sync android. - Dev run:
npx cap run android(emulator or device frommobile action=devices). - Debug APK (
exec background=true):cd android && ./gradlew assembleDebug(Windowsgradlew.bat). Outputandroid/app/build/outputs/apk/debug/app-debug.apk. - Release signing: keystore outside the repo,
keytool -genkeypair -v -keystore ~/.navin/keys/<app>.jks -alias <app> -keyalg RSA -keysize 2048 -validity 10000; inandroid/app/build.gradle:signingConfigs { release { storeFile file(System.getenv("ANDROID_KEYSTORE_PATH")) storePassword System.getenv("ANDROID_KEYSTORE_PASSWORD") keyAlias System.getenv("ANDROID_KEY_ALIAS") keyPassword System.getenv("ANDROID_KEY_PASSWORD") } } buildTypes { release { signingConfig signingConfigs.release } } - Release:
./gradlew bundleRelease(.aab, Play Store) and./gradlew assembleRelease(.apk). - iOS:
npx cap sync ios,xcodebuild -workspace ios/App/App.xcworkspace -scheme App -configuration Release archive -archivePath build/App.xcarchive, thenxcodebuild -exportArchivefor the.ipa. appfactory action=artifacts target=<id>.
Verification
APK installs and launches (app-device-tester); .aab exists.
Failure modes and fixes
See app-build-repair: JDK mismatch, SDK licenses, minSdk, white screen, CORS, cookies on capacitor://localhost.
Deliverable
.apk / .aab / .ipa paths; report step build.
