name: mobile-sim description: Drive iOS simulators (Xcode DeviceHub) and Android emulators through one headless command — touch, multi-finger and scripted gestures, edge gestures, buttons, typing, rotation, foldables (iPhone Duo hinge), screenshots, video/GIF/contact sheets with touch indicators, on-screen text lookup, settings, per-process stats — plus the browser debugger (Safari Web Inspector / Chrome DevTools): JavaScript, console, performance, network log, service workers, site reset, push, offline and throttled networks. Use for PWA / web app development and testing on simulated phones, or any task that operates or inspects a simulated iPhone or Android device.
What does mobile-sim do?
<this skill's folder>/mobile [ios|android] COMMAND [ARGS] # `mobile help` lists every command
(e.g. ~/.claude/skills/mobile-sim/mobile or ~/.codex/skills/mobile-sim/mobile)
- Platform: the first argument, else
MOBILE_PLATFORM, else whichever one is running. Device:MOBILE_DEVICE(UDID / adb serial), else the only booted one — with several booted it stops and lists them (another session may be driving one). - Coordinates are points as currently shown on both platforms (iOS points, Android dp) — the same units as CSS px in the page, so
getBoundingClientRectvalues,textoutput andtapagree.sizeprints width, height and the pixel scale (screenshot px = points × scale). - Every command exits non-zero with a reason. Helpers compile on first use (Xcode's
swiftc); nothing else is installed.
Setup (once)
- iOS: Xcode with an iOS runtime (
xcodebuild -downloadPlatform iOS), thenmobile ios boot "iPhone 18 Pro Max". - Android, no Android Studio or Java:
curl -fsSL https://dl.google.com/android/cli/latest/darwin_arm64/android -o ~/.local/bin/android && chmod +x ~/.local/bin/android,android --no-metrics sdk install emulator platform-tools system-images/android-36/google_apis_playstore/arm64-v8a(~2.5 GB),android --no-metrics emulator create medium_phone(orfoldable_1_1),mobile android boot medium_phone. First Chrome start:mobile taptext "Use without an account", thenNo thanks,Got it.
Commands
| Area | Commands |
|---|---|
| Device | devices · boot NAME (headless) · size · shot [px] (iOS in its device frame; MOBILE_FRAME=0 bare) |
| Touch | tap X Y [hold] · doubletap · swipe X1 Y1 X2 Y2 [sec] [hold] · pinch CX CY R1 R2 [sec] · rotate CX CY R DEG [sec] · twofinger X1 Y1 X2 Y2 [sec] |
| Scripted gesture | gesture "down X Y [X2 Y2]; move X Y [X2 Y2] [sec]; hold SEC; run CMD; up" — fingers stay down between steps; run executes a shell command mid-gesture, with mobile on PATH for this device (run mobile ios shot 400, run mobile ios eval …) |
| System | edge left|right|top|bottom|topright (back/forward, notifications, home, Control Center) · button NAME [hold] · buttons (every name button takes) · type TEXT · key CODE |
| Screen | text (visible text with centre; Android: accessibility tree, iOS: OCR) · taptext LABEL [wait] [exact] · orient portrait|landscape-left|landscape-right|pud · hinge [DEG] (iPhone Duo / foldable AVD; later commands follow the live screen) |
| Apps | open URL · launch ID · kill ID · apps · openapp LABEL (Home Screen, web apps too) · install APP.app|APK · uninstall ID (always names its target; iOS also a web app by title or URL; Android chrome-shortcuts removes all of Chrome's plain web shortcuts) · clipboard [TEXT] (get / set; Android goes through the Chrome page in front) |
| Settings | appearance light|dark · contrast enabled|disabled · textsize NAME (iOS size names) · locale de-DE · location LAT LON · statusbar [clean|clear] (09:41) |
| Web | pages · eval [-p M] JS (runs as a user gesture; top-level await — multi-statement code with await ends in return; prints console output it caused) · console [-p M] [sec] · reload · tapel [-p M] SELECTOR (a real touch at the element, checked where it landed) · perf [-p M] [sec] · frames [-p M] start [ms] … frames stop (frames slower than ms, default 40, with touches and route changes) · net [-p M] [sec] [reload] · sw [list|update|unregister] · reset-site (iOS clears HttpOnly cookies too) · network offline|slow-3g|fast-3g|4g|online (page and service worker; iOS: network PROFILE DEV_PORT once, then open the page through http://localhost:8900/; network stop) |
| Push | push-permission [APP] · push TITLE [BODY] [APP] — iOS: a real notification from the installed web app; Android: the service worker's push handler runs with event.data = {title, body} |
| Stats | stats [MATCH] (per process) · mem MATCH (iOS: footprint/vmmap/heap; Android: meminfo of a package) |
| Video | record start [FILE] · record stop · sheet VIDEO [frames] (one labelled grid image) · gif VIDEO [fps] [width] |
-p M picks a page by URL or title; default: the page on screen. MOBILE_SHOW_TOUCHES=1: touch indicators (iOS draws dots on sheets/GIFs and on shot inside gesture … run; Android shows its own dots in recordings).
Working efficiently
- Prefer text: read state with
eval, act withtapel/taptext; take a smallshot 400only for visuals. - Animations:
record start, drive withgesture(hold/runto freeze mid-gesture),record stop, then read onesheet VIDEO 12. Jank:frames start, drive,frames stop— which frames were slow and when, next to the touches. - Batch steps in one shell call. iOS allows one inspector client per page: don't run web commands in parallel there.
PWA loop
- Serve locally.
open http://localhost:PORT/works on both (Android sets upadb reverse): a secure context, so service workers work. - Install (once, by hand via the commands):
- iOS:
open URL; tap Safari's page-menu icon left of the address (textfinds the address; OCR reads the icon as "=");taptext Share 5;taptext "View More" 5;taptext "Add to Home Screen" 5;taptext Add 5 exact. - Android:
open URL;taptext "More options";taptext "Add to Home screen" 3;taptext Install 3 exact;taptext "Add to home screen" 3. Thenopenapp NAME;eval "matchMedia('(display-mode: standalone)').matches"is true.
- iOS:
push-permissiononce; then edit →reload→eval/tapel/gesture/console 3/perf 3/frames start…stop/net reload/orient.- Offline and slow networks:
network offline(orslow-3g) /net reload/network online. Android emulates it in Chrome for the page and its service workers. iOS 27.2's inspector can't, so a local proxy shapes the dev server:mobile ios network slow-3g 8080, thenopen http://localhost:8900/(one origin for all profiles; offline refuses connections). To throttle the whole Mac instead, use Apple's Network Link Conditioner (Additional Tools for Xcode).reset-sitereturns to a first visit.
Layout
mobile (entry, platform choice) · lib/common.sh (constants, state, build, shared JavaScript, shared commands) · lib/ios.sh, lib/android.sh (each platform's commands) · swift/shared/ (gesture engine and orientation mapping, inspector value printing, request log) · swift/<helper>/ (simhid: iOS input over XPC to dtuhidd · simweb: Safari inspector over webinspectord · simdev: runs inside the iOS simulator (hinge, display swap, stats) · media: video/OCR/frames/images · throttle: iOS network proxy · droidhid: Android touch via the emulator console · droidweb: Chrome DevTools) · bin/ (built helpers). State lives in $TMPDIR/mobile-sim/, per device (<device>.shot.png, …), so sessions on different devices never overwrite each other.
Limits
- iOS:
networkcovers only the dev server behind the proxy (a different origin from the server's own port), not other hosts.pushruns no service-worker code (iOS 27.2 lists no service workers to the inspector; no real Web Push in the simulator) — test the handler on Android. - iOS: a refused notification permission sticks until the web app is removed (
uninstall, add again). Native UI is read by OCR (icons without text need coordinates). iPhone apps don't rotate upside down. Duo inner-screen shots are unframed; its orientation is read from an open page, else assumed landscape-right. - Android: screenshots are unframed; recordings stop after 180 s before Android 14; localhost installs are Chrome shortcuts, not WebAPKs (share targets and app info differ);
clipboardneeds a Chrome page in front; a page needs Chrome's location permission beforelocationreaches it. - CPU/energy come from the Mac's CPU — compare runs on the same machine. iPhone Camera Control isn't simulated.