Skip to content

Commit 3ec85f2

Browse files
committed
update docs
1 parent 8c61f91 commit 3ec85f2

3 files changed

Lines changed: 85 additions & 49 deletions

File tree

wiki/guides/android-guide.md

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,11 @@ Create or modify your `devbox.json` to include the Android plugin:
3333
"packages": {
3434
"jdk17": "latest",
3535
"gradle": "latest"
36-
},
37-
"env": {
38-
"ANDROID_APP_APK": "app/build/outputs/apk/debug/app-debug.apk"
3936
}
4037
}
4138
```
4239

43-
The `include` line adds the plugin. The `packages` section adds your build tooling. Set `ANDROID_APP_APK` to where your build outputs the APK.
40+
The `include` line adds the plugin. The `packages` section adds your build tooling. APK paths are auto-detected at runtime when you deploy.
4441

4542
### Initial Setup
4643

@@ -228,12 +225,9 @@ The plugin provides emulator and device management. Build and deploy commands ar
228225
"jdk17": "latest",
229226
"gradle": "latest"
230227
},
231-
"env": {
232-
"ANDROID_APP_APK": "app/build/outputs/apk/debug/app-debug.apk"
233-
},
234228
"shell": {
235229
"scripts": {
236-
"build": [
230+
"build:android": [
237231
"gradle assembleDebug --info"
238232
],
239233
"start:app": [
@@ -250,7 +244,7 @@ With these scripts defined, you can:
250244

251245
```bash
252246
# Build the APK
253-
devbox run build
247+
devbox run build:android
254248

255249
# Build, install, and launch on the emulator
256250
devbox run start:app
@@ -259,7 +253,23 @@ devbox run start:app
259253
devbox run start:app min
260254
```
261255

262-
The `android.sh run` command waits for the emulator to boot, installs the APK, and launches the app. The app's package name is auto-detected from the APK.
256+
**How APK auto-detection works:** The `android.sh run` command waits for the emulator to boot, then auto-detects the APK using this precedence chain:
257+
258+
1. `ANDROID_APP_APK` env var — if set, resolves the path/glob relative to project root
259+
2. Recursive search of the project directory for `.apk` files, skipping `.gradle/`, `build/intermediates/`, `node_modules/`, and `.devbox/`
260+
3. Recursive search of the current working directory (if different from project root)
261+
262+
The app's package name and launch activity are extracted from the APK automatically.
263+
264+
In most projects, step 2 finds the right APK with no configuration. If auto-detection picks the wrong APK (e.g., multiple build variants), set `ANDROID_APP_APK` explicitly:
265+
266+
```json
267+
{
268+
"env": {
269+
"ANDROID_APP_APK": "app/build/outputs/apk/debug/app-debug.apk"
270+
}
271+
}
272+
```
263273

264274
See the [Android example project](../../examples/android/) for a complete working setup.
265275

@@ -360,7 +370,6 @@ Configure the plugin by setting environment variables in `devbox.json`:
360370
{
361371
"env": {
362372
"ANDROID_DEFAULT_DEVICE": "max",
363-
"ANDROID_APP_APK": "app/build/outputs/apk/debug/app-debug.apk",
364373
"ANDROID_BUILD_TOOLS_VERSION": "36.1.0",
365374
"ANDROID_COMPILE_SDK": "36",
366375
"ANDROID_TARGET_SDK": "36"
@@ -370,7 +379,7 @@ Configure the plugin by setting environment variables in `devbox.json`:
370379

371380
Key variables:
372381
- `ANDROID_DEFAULT_DEVICE` - Default device when none specified
373-
- `ANDROID_APP_APK` - Path or glob pattern for APK
382+
- `ANDROID_APP_APK` - Path or glob pattern for APK (empty = auto-detect)
374383
- `ANDROID_BUILD_TOOLS_VERSION` - Build tools version
375384
- `ANDROID_COMPILE_SDK` - Compile SDK version
376385
- `ANDROID_TARGET_SDK` - Target SDK version
@@ -482,10 +491,9 @@ Run `devbox shell` after changing `devbox.json` to apply the new values. To rese
482491

483492
**Solutions**:
484493

485-
1. Verify APK path is correct:
494+
1. Verify the APK exists (check your build output directory):
486495
```bash
487-
echo $ANDROID_APP_APK
488-
ls -l $ANDROID_APP_APK
496+
find . -name '*.apk' -not -path '*/.gradle/*' -not -path '*/intermediates/*'
489497
```
490498

491499
2. Check if app is already installed:

wiki/guides/ios-guide.md

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ The iOS plugin enables reproducible iOS development by automatically discovering
1010
- **Automatic Xcode discovery**: Multi-strategy detection with caching for fast shell initialization
1111
- **Device management**: JSON-based device definitions with CLI commands for creating, updating, and managing simulators
1212
- **Simulator control**: Scripts for starting and stopping simulators
13+
- **App deployment**: `ios.sh run` auto-detects your `.app` bundle, extracts the bundle ID, and deploys to the simulator
1314

14-
The plugin does **not** provide build or deploy commands. Every project has different Xcode configurations (project vs. workspace, different schemes, different derived data paths), so you define those in your own `devbox.json`. See [Adding Build Scripts](#adding-build-and-deploy-scripts) for patterns.
15+
The plugin auto-detects your Xcode project, `.app` path, and bundle ID at runtime. You define a `build:ios` script in your `devbox.json` to handle the actual Xcode build, then `ios.sh run` handles everything else. See [Adding Build Scripts](#adding-build-and-deploy-scripts) for patterns.
1516

1617
Pure shells with `devbox run --pure` create test-specific simulators and clean up after execution, ensuring isolated, reproducible testing.
1718

@@ -34,7 +35,7 @@ Create or modify your `devbox.json` to include the iOS plugin:
3435
}
3536
```
3637

37-
The Xcode project, build scheme, bundle ID, and app path are all auto-detected at runtime. Use `-derivedDataPath DerivedData` in your xcodebuild command to keep build output project-local.
38+
Use `-derivedDataPath DerivedData` in your xcodebuild command to keep build output project-local.
3839

3940
### Initial Setup
4041

@@ -250,9 +251,26 @@ The plugin provides simulator and device management. Build and deploy commands a
250251
}
251252
```
252253

253-
The `ios.sh run` command starts the simulator, builds (via `build:ios`), auto-detects the .app bundle, extracts the bundle ID, installs, and launches. The `${1:-}` syntax passes an optional device nickname through.
254+
The `ios.sh run` command handles the full deployment pipeline: starts the simulator, runs your `build:ios` script, auto-detects the `.app` bundle, extracts the bundle ID from `Info.plist`, installs, and launches. The `${1:-}` syntax passes an optional device nickname through.
254255

255-
With these scripts defined, you can:
256+
**How app auto-detection works:** After building, `ios.sh run` finds your `.app` bundle using this precedence chain:
257+
258+
1. `IOS_APP_ARTIFACT` env var — if set, resolves the path/glob relative to project root
259+
2. `xcodebuild -showBuildSettings` — queries your Xcode project for BUILT_PRODUCTS_DIR + FULL_PRODUCT_NAME
260+
3. Recursive search of the project directory for `.app` bundles, skipping `Pods/`, `.build/`, `node_modules/`, `.devbox/`, and similar directories
261+
4. Recursive search of the current working directory (if different from project root)
262+
263+
In most projects, step 2 or 3 finds the right `.app` automatically with no configuration needed. If auto-detection doesn't work (e.g., multiple `.app` bundles, non-standard project layout), set `IOS_APP_ARTIFACT` explicitly:
264+
265+
```json
266+
{
267+
"env": {
268+
"IOS_APP_ARTIFACT": "DerivedData/Build/Products/Debug-iphonesimulator/MyApp.app"
269+
}
270+
}
271+
```
272+
273+
With the scripts defined above, you can:
256274

257275
```bash
258276
# Build the app
@@ -275,16 +293,11 @@ Typical development session:
275293
# 1. Enter devbox shell
276294
devbox shell
277295

278-
# 2. Start simulator
279-
devbox run start:sim max
280-
281-
# 3. Build and deploy app (using your custom scripts)
282-
devbox run build
283-
devbox run start:app max
296+
# 2. Build and deploy (starts simulator, builds, installs, and launches)
297+
devbox run start:app
284298

285-
# 4. Make code changes, rebuild, and redeploy
286-
devbox run build
287-
devbox run start:app max
299+
# 3. Make code changes, rebuild, and redeploy
300+
devbox run start:app
288301

289302
# 5. Stop simulator when done
290303
devbox run stop:sim

wiki/guides/quick-start.md

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,11 @@ Replace the contents of your `devbox.json` with:
3838
"packages": {
3939
"jdk17": "latest",
4040
"gradle": "latest"
41-
},
42-
"env": {
43-
"ANDROID_APP_APK": "app/build/outputs/apk/debug/app-debug.apk"
4441
}
4542
}
4643
```
4744

48-
The `include` line adds the Android plugin from GitHub. Devbox downloads the Android SDK, emulator, and device management tools automatically. The `packages` section adds JDK and Gradle for building your app. Set `ANDROID_APP_APK` to the path where your build outputs the APK.
45+
The `include` line adds the Android plugin from GitHub. Devbox downloads the Android SDK, emulator, and device management tools automatically. The `packages` section adds JDK and Gradle for building your app.
4946

5047
> **Note:** Plugins are included via URL in `devbox.json`, not with `devbox add`. You cannot use `devbox add plugin:android`.
5148
@@ -97,12 +94,9 @@ The plugin provides emulator and device management. Build and deploy commands ar
9794
"jdk17": "latest",
9895
"gradle": "latest"
9996
},
100-
"env": {
101-
"ANDROID_APP_APK": "app/build/outputs/apk/debug/app-debug.apk"
102-
},
10397
"shell": {
10498
"scripts": {
105-
"build": [
99+
"build:android": [
106100
"gradle assembleDebug --info"
107101
],
108102
"start:app": [
@@ -119,7 +113,7 @@ Now you can build and deploy:
119113

120114
```sh
121115
# Build the APK
122-
devbox run build
116+
devbox run build:android
123117

124118
# Build, install, and launch on the default device
125119
devbox run start:app
@@ -128,7 +122,19 @@ devbox run start:app
128122
devbox run start:app min
129123
```
130124

131-
The `android.sh run` command waits for the emulator to boot, installs the APK, and launches the app. The app's package name is auto-detected from the APK.
125+
The `android.sh run` command waits for the emulator to boot, then auto-detects, installs, and launches the APK. The app's package name is extracted from the APK automatically.
126+
127+
**How APK auto-detection works:** The `run` command searches your project for `.apk` files, skipping build caches like `.gradle/`, `build/intermediates/`, `node_modules/`, and `.devbox/`. If your build outputs the APK to a standard location (e.g., `app/build/outputs/apk/`), it will be found automatically.
128+
129+
If auto-detection picks the wrong APK or you want to be explicit, set `ANDROID_APP_APK` in your `devbox.json` env. This accepts a path or glob pattern relative to your project root:
130+
131+
```json
132+
{
133+
"env": {
134+
"ANDROID_APP_APK": "app/build/outputs/apk/debug/app-debug.apk"
135+
}
136+
}
137+
```
132138

133139
### 6. Stop the Emulator
134140

@@ -165,7 +171,7 @@ Replace the contents of your `devbox.json` with:
165171
}
166172
```
167173

168-
The `include` line adds the iOS plugin from GitHub. The plugin discovers your Xcode installation and provides simulator management tools. The Xcode project, build scheme, bundle ID, and app path are all auto-detected at runtime.
174+
The `include` line adds the iOS plugin from GitHub. The plugin discovers your Xcode installation, manages simulators, and auto-detects your Xcode project, `.app` bundle, and bundle ID when deploying.
169175

170176
> **Note:** Plugins are included via URL in `devbox.json`, not with `devbox add`.
171177
@@ -226,8 +232,6 @@ The plugin provides simulator and device management. Build and deploy commands a
226232

227233
As with the Android example, `${1:-}` passes an optional device nickname through (e.g., `devbox run start:app min`). If omitted, the default device is used.
228234

229-
The `ios.sh run` command starts the simulator, builds (via `build:ios`), auto-detects the .app bundle (via xcodebuild settings or recursive search), extracts the bundle ID from `Info.plist`, installs, and launches.
230-
231235
Now you can build and deploy:
232236

233237
```sh
@@ -238,6 +242,23 @@ devbox run build:ios
238242
devbox run start:app
239243
```
240244

245+
**How app auto-detection works:** The `ios.sh run` command starts the simulator, runs your `build:ios` script, then auto-detects the `.app` bundle. It uses this precedence chain:
246+
247+
1. Query `xcodebuild -showBuildSettings` for the built products path (works when your project has an `.xcodeproj` or `.xcworkspace` in the project root)
248+
2. Recursive search of the project directory for `.app` bundles, skipping `Pods/`, `.build/`, `node_modules/`, `.devbox/`, and similar directories
249+
250+
The bundle ID is extracted automatically from the `.app`'s `Info.plist`.
251+
252+
If auto-detection picks the wrong `.app` or your project structure is non-standard, set `IOS_APP_ARTIFACT` in your `devbox.json` env. This accepts a path or glob pattern relative to your project root:
253+
254+
```json
255+
{
256+
"env": {
257+
"IOS_APP_ARTIFACT": "DerivedData/Build/Products/Debug-iphonesimulator/MyApp.app"
258+
}
259+
}
260+
```
261+
241262
Use `-derivedDataPath DerivedData` in your xcodebuild command to keep build output project-local.
242263

243264
### 6. Stop the Simulator
@@ -277,14 +298,11 @@ Replace the contents of your `devbox.json` with:
277298
"watchman@latest",
278299
"jdk17@latest",
279300
"gradle@latest"
280-
],
281-
"env": {
282-
"ANDROID_APP_APK": "android/app/build/outputs/apk/debug/app-debug.apk"
283-
}
301+
]
284302
}
285303
```
286304

287-
The React Native plugin automatically includes both the Android and iOS plugins. The iOS app project, scheme, bundle ID, and artifact path are all auto-detected at runtime.
305+
The React Native plugin automatically includes both the Android and iOS plugins. APK and `.app` paths are auto-detected at runtime.
288306

289307
> **Note:** Plugins are included via URL in `devbox.json`, not with `devbox add`.
290308
@@ -309,9 +327,6 @@ The plugin provides emulator/simulator control, device management, and Metro bun
309327
"jdk17@latest",
310328
"gradle@latest"
311329
],
312-
"env": {
313-
"ANDROID_APP_APK": "android/app/build/outputs/apk/debug/app-debug.apk"
314-
},
315330
"shell": {
316331
"scripts": {
317332
"build:android": [

0 commit comments

Comments
 (0)