Files
orca/mobile/plugins/android-inspectable-release.js
T
Jinwoo-H 979cf30247 feat(mobile): opt-in inspectable Android release build for hosted WebView devtools
`-PorcaInspectableRelease=true` marks the release variant debuggable through an
Expo config plugin and flips a build config field the shell's inspection policy
reads. The OS debuggable flag stays a hard requirement, so a shipped production
APK can never be inspected regardless of the Gradle property. Default builds are
byte-for-byte unchanged.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
2026-09-03 22:52:21 -04:00

27 lines
1.1 KiB
JavaScript

const { withAppBuildGradle } = require('expo/config-plugins')
// Why: android/ is generated and gitignored, so the opt-in has to be reapplied on every prebuild.
const RELEASE_BLOCK = ' release {\n'
const DEBUGGABLE_LINE =
' // Dogfood opt-in: -PorcaInspectableRelease=true keeps the release bundle but marks the APK debuggable.\n' +
" debuggable = (findProperty('orcaInspectableRelease') ?: 'false').toBoolean()\n"
function addInspectableReleaseOptIn(contents) {
if (contents.includes('orcaInspectableRelease')) {
return contents
}
if (!contents.includes(RELEASE_BLOCK)) {
throw new Error('android app/build.gradle has no release buildType block to make inspectable')
}
return contents.replace(RELEASE_BLOCK, RELEASE_BLOCK + DEBUGGABLE_LINE)
}
module.exports = function withAndroidInspectableRelease(config) {
return withAppBuildGradle(config, (cfg) => {
cfg.modResults.contents = addInspectableReleaseOptIn(cfg.modResults.contents)
return cfg
})
}
module.exports.addInspectableReleaseOptIn = addInspectableReleaseOptIn