A production setup
Developer tools are for staging and debug builds. This guide shows how a build chooses, and how to prove a production build has no devtools code.
Choose per build
- Kotlin
- Dart
On Android, give each variant one artifact:
// sample: kotlin-lib/sample/androidApp/build.gradle.kts#devtools-variants
"productionDebugImplementation"(projects.sinewDevtoolsUi)
"stagingImplementation"(projects.sinewDevtoolsUi)
"productionReleaseImplementation"(projects.sinewDevtoolsNoop)
Then wrap the app in the platform entry point, never in shared code:
// sample: kotlin-lib/sample/shared/src/jvmMain/kotlin/com/srctool/sinew/sample/Main.kt#devtools-entry
fun main() = application {
Window(onCloseRequest = ::exitApplication, title = "Sinew") {
SinewDevTools(ribbon = BuildRibbon("Sinew sample")) { SampleApp() } // sinew.devtools picks real or no-op
}
}
The no-op artifact has the same API with nothing behind it, so this code compiles against both, and SinewDevTools only calls its content.
Prove it
Sinew's own CI does this for its sample and example, and you can do the same for your app:
- Kotlin
- Dart
Build the production outputs and search them for com.srctool.sinew.devtools names. Anything the no-op doesn't declare is real devtools code. Sinew's checkDevToolsGating task does this for the APK, the desktop jar, the wasm bundle and the iOS framework, and checks the real-devtools builds the other way, so a search that can't see devtools code fails instead of passing.
Good to know
- Redaction hides secrets before anything is stored, but devtools are still not for production: the gate is the guarantee, redaction is the second line.
- A tester's replay of a request that hid a secret is not offered, and a non-GET replay asks first.