Skip to content

feat: pass arguments and environment variables to apps launch - #531

Merged
gmegidish merged 2 commits into
mainfrom
feat/launch-args-env
Nov 13, 2026
Merged

gmegidish merged 2 commits into
mainfrom
feat/launch-args-env

Conversation

@mobile-kevin

@mobile-kevin mobile-kevin commented Oct 18, 2026 •

Copy link
Copy Markdown
Collaborator

Adds launch arguments and environment variables to apps launch, for the "App launch options" roadmap item (mobile-next/mobile-mcp#370).

# iOS
mobilecli apps launch com.example.app --device <id> --arg -FeatureX --arg YES --env API_URL=https://staging.example.com
# Android
mobilecli apps launch com.example.app --device <id> --arg featureX=true --arg apiUrl=https://staging.example.com
  • --arg can be repeated. --env KEY=VALUE can also be repeated. Values may contain = or be empty.
  • On a real iOS device, both are passed through instruments ProcessControl (LaunchAppWithArgs).
  • On the iOS Simulator, arguments go after the bundle id in simctl launch, and env vars are passed as SIMCTL_CHILD_<KEY>.
  • On Android, each --arg must be key=value and becomes a string intent extra, am start --es key value. The app reads it from its launch intent (getIntent().getStringExtra("key")). An argument without = is an error. --env is an error because Android apps have no environment.
  • The device.apps.launch JSON-RPC method accepts args (string[]) and env (object). RemoteDevice forwards both.

Testing

  • Unit tests for simctlLaunchArgs, simctlLaunchEnv, launchExtras, launchArgs with extras, parseLaunchEnv, and the Android rejections.
  • iOS 26 simulator: ps eww on the launched Settings process shows -AppleLanguages (he) as arguments and FOO=bar in its environment.
  • Physical Android device: launching Settings with --arg "mcpFlag=hello world; echo pwned" succeeds, and dumpsys activity shows the intent (has extras). The value stays one shell-quoted word. --arg -FeatureX is rejected.
  • Not yet tested on a real iOS device.

Summary by CodeRabbit

  • New Features
    • App launch commands now accept repeated arguments and environment variables.
    • On iOS, arguments and environment variables are passed to the app at launch. On Android, arguments can be supplied as key=value intent extras.
    • Simulator launches now pass configured environment variables to the app.
  • Limitations
    • Android launches return an error if environment variables are provided or arguments are not in key=value format.
    • Environment entries must include a nonempty key and an = sign.

@coderabbitai

coderabbitai Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review.

Walkthrough

App launch requests now accept arguments and environment variables. The CLI and server forward these options to device launch implementations. iOS and simulator launches apply them, remote launches include them in RPC parameters, and Android rejects non-empty environment options and invalid arguments.

Changes: App Launch Options

Layer / File(s) Summary
Launch request inputs and forwarding
commands/apps.go, server/server.go, cli/flags.go, cli/apps.go, cli/apps_test.go, devices/common.go
Launch request types and CLI flags carry arguments and environment variables. The CLI parses KEY=VALUE entries, and the command validates environment keys before mapping the options into LaunchOptions. The server forwards the parsed options.
Platform launch handling
devices/ios.go, devices/simulator.go, devices/remote.go, devices/android.go, devices/android_launch_test.go, devices/simulator_launch_test.go
iOS forwards configured arguments and environment entries. The simulator appends arguments and passes sorted SIMCTL_CHILD_ environment entries. Remote launch requests include non-empty options. Android converts valid key=value arguments to string intent extras and rejects environment options. Tests cover parsing, formatting, ordering, and platform rejection.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant CLI
  participant AppsLaunchParams
  participant handleAppsLaunch
  participant LaunchAppCommand
  participant Device
  CLI->>AppsLaunchParams: Send args and env
  AppsLaunchParams->>handleAppsLaunch: Provide parsed args and env
  handleAppsLaunch->>LaunchAppCommand: Forward AppRequest
  LaunchAppCommand->>Device: Pass Arguments and Env in LaunchOptions
Loading

Suggested reviewers: gmegidish

Merge Risk: Minimal · previous review 8d6ae

The change adds launch arguments and environment variables to app launch. No concrete merge-blocking issue was found in the reviewed changes.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "feat: pass arguments and environment variables to apps launch" matches the main change. The changeset adds repeatable --arg and --env options to apps launch, forwards args and env through A…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "feat: pass arguments and environment variables to apps launch" matches the main change. The changeset adds repeatable --arg and --env options to apps launch, forwards args and env through AppRequest, the server, RemoteDevice, and the device launch paths for iOS, simulator, and Android. The title is specific and concise. It omits the Android validation rules, which is acceptable.

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 3ae1c94 and 8d6aee7.

Files ignored due to path filters: 2

  • README.md is excluded by !**/*.md
  • skills/mobilecli/reference.md is excluded by !**/*.md
Files selected for processing: 3

  • devices/common.go
  • devices/ios.go
  • server/server.go

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.

@mobile-kevin mobile-kevin changed the title feat: pass arguments and environment variables to apps launch on iOS feat: pass arguments and environment variables to apps launch Oct 18, 2026
@gmegidish
gmegidish force-pushed the feat/launch-args-env branch from 3ae1c94 to 8d6aee7 Compare November 13, 2026 10:48
apps launch takes repeatable --arg and --env KEY=VALUE flags. On a real
iOS device they go through ProcessControl, on a simulator as simctl launch
arguments and SIMCTL_CHILD_ variables. Android has no app arguments or
environment, so both are rejected there. The device.apps.launch JSON-RPC
method accepts the same as args and env.
Each --arg on Android must be key=value and becomes am start --es key
value, which the app reads from its launch intent. An argument without
'=' is an error. --env stays iOS-only.
@gmegidish
gmegidish force-pushed the feat/launch-args-env branch from 8d6aee7 to 15f94aa Compare November 13, 2026 11:56
@gmegidish
gmegidish merged commit f2e8361 into main Nov 13, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants