### Start Instruments Source: https://github.com/facebook/idb/blob/main/website/docs/commands.mdx Starts instruments running connected to the target. ```bash idb instruments TEMPLATE ``` -------------------------------- ### Install idb_companion Prerequisites Source: https://github.com/facebook/idb/blob/main/README.md Installs protobuf and gRPC Swift plugins required for building idb_companion. ```bash brew install protobuf swift-protobuf grpc-swift ``` -------------------------------- ### Install an application Source: https://github.com/facebook/idb/blob/main/website/docs/commands.mdx Install a given .app or .ipa file onto the target. Ensure the app's target architecture matches the target's architecture. ```bash idb install /path/to/testApp.app ``` -------------------------------- ### List installed applications Source: https://github.com/facebook/idb/blob/main/website/docs/commands.mdx List all applications installed on the target, along with their metadata such as bundle ID, name, install type, architectures, and running status. This command operates on the default or specified target. ```bash idb list-apps ``` -------------------------------- ### Install idb Companion with Homebrew Source: https://github.com/facebook/idb/blob/main/website/docs/installation.mdx Installs the idb companion process, which is required for remote communication with simulators and devices. Ensure Homebrew is installed and Xcode is fully set up. ```bash brew tap facebook/fb brew install idb-companion ``` -------------------------------- ### Install XCTest Bundle Source: https://github.com/facebook/idb/blob/main/website/docs/guided-tour.mdx Installs a provided XCTest bundle onto the simulator. This is a prerequisite for running tests. ```bash idb xctest install Fixtures/Binaries/iOSUnitTestFixture.xctest ``` -------------------------------- ### Install Build Dependencies for idb_companion Source: https://github.com/facebook/idb/blob/main/website/docs/development.mdx Install XcodeGen and protobuf tools via Homebrew, which are required for building the idb_companion. ```bash # XcodeGen generates the Xcode projects from the project.yml files brew install xcodegen # protobuf and swift-protobuf are used to generate the gRPC Swift bindings from # idb.proto (grpc-swift itself is resolved as a Swift Package dependency) brew install protobuf swift-protobuf ``` -------------------------------- ### Install and List Test Bundles via idb Source: https://github.com/facebook/idb/blob/main/website/docs/test-execution.mdx Commands to install a test bundle, list available bundles, and inspect test cases within a specific bundle. ```bash $ idb xctest install Fixtures/Binaries/iOSUnitTestFixture.xctest Installed: com.facebook.iOSUnitTestFixture $ idb xctest list com.facebook.iOSUnitTestFixture | iOSUnitTestFixture | x86_64, i386 $ idb xctest list-bundle com.facebook.iOSUnitTestFixture iOSUnitTestFixtureTests/testHostProcessIsMobileSafari iOSUnitTestFixtureTests/testHostProcessIsXctest iOSUnitTestFixtureTests/testIsRunningInIOSApp iOSUnitTestFixtureTests/testIsRunningInMacOSXApp iOSUnitTestFixtureTests/testIsRunningOnIOS iOSUnitTestFixtureTests/testIsRunningOnMacOSX iOSUnitTestFixtureTests/testPossibleCrashingOfHostProcess iOSUnitTestFixtureTests/testPossibleStallingOfHostProcess iOSUnitTestFixtureTests/testWillAlwaysFail iOSUnitTestFixtureTests/testWillAlwaysPass ``` -------------------------------- ### idb_companion Output Example Source: https://github.com/facebook/idb/blob/main/website/docs/development.mdx Example of the JSON output from idb_companion indicating the gRPC port it has bound to. ```json {"grpc_port":10882} ``` -------------------------------- ### Install App and Make Debuggable Source: https://github.com/facebook/idb/blob/main/website/docs/fbdevicecontrol.mdx Installs an application on an iOS device and persists a copy to the host machine for debugging purposes. This is required for `lldb` to symbolicate symbols. ```bash # Install an app, also persisting it to disk so that idb can later find it when launching a debugserver $ idb install --make-debuggable /path/to/SomeApp.app ``` -------------------------------- ### Install a .dylib File with idb Source: https://github.com/facebook/idb/blob/main/website/docs/commands.mdx Installs a dynamic library (.dylib) file onto the target device, making it available for injection into apps upon launch. ```bash idb dylib install test.dylib ``` -------------------------------- ### List Available Simulators/Devices Source: https://github.com/facebook/idb/blob/main/README.md Lists all simulators installed on the system, showing details like name, UDID, status, and companion connection status. ```bash $ idb list-targets ... iPhone X | 569C0F94-5D53-40D2-AF8F-F4AA5BAA7D5E | Shutdown | simulator | iOS 12.2 | x86_64 | No Companion Connected iPhone Xs | 2A1C6A5A-0C67-46FD-B3F5-3CB42FFB38B5 | Shutdown | simulator | iOS 12.2 | x86_64 | No Companion Connected iPhone Xs Max | D3CF178F-EF61-4CD3-BB3B-F5ECAD246310 | Shutdown | simulator | iOS 12.2 | x86_64 | No Companion Connected iPhone Xʀ | 74064851-4B98-473A-8110-225202BB86F6 | Shutdown | simulator | iOS 12.2 | x86_64 | No Companion Connected ... ``` -------------------------------- ### Start idb_companion gRPC Server Source: https://github.com/facebook/idb/blob/main/website/docs/commands.mdx Starts a companion server for a specific iOS Simulator or Device UDID. Fails if UDID is not found. Supports additional switches for behavior alteration. ```bash idb_companion --udid UDID ``` -------------------------------- ### List Installed XCTest Bundles Source: https://github.com/facebook/idb/blob/main/website/docs/guided-tour.mdx Verifies that the XCTest bundle has been successfully installed on the simulator. ```bash idb xctest list ``` -------------------------------- ### Execute Basic idb Commands Source: https://github.com/facebook/idb/blob/main/website/docs/guided-tour.mdx Launches an application, starts recording, or begins logging. Ensure to specify the correct simulator using the --udid flag for these commands. ```bash idb launch com.apple.Maps ``` ```bash idb record ``` ```bash idb log ``` -------------------------------- ### List Apps Installed on a Target Source: https://github.com/facebook/idb/blob/main/README.md Lists all applications installed on a specific simulator or device, identified by its UDID. Shows bundle ID, name, type, architecture, and debuggability. ```bash $ idb list-apps --udid 74064851-4B98-473A-8110-225202BB86F6 com.apple.Maps | Maps | system | x86_64 | Not running | Not Debuggable com.apple.MobileSMS | MobileSMS | system | x86_64 | Not running | Not Debuggable com.apple.mobileslideshow | MobileSlideShow | system | x86_64 | Not running | Not Debuggable com.apple.mobilesafari | MobileSafari | system | x86_64 | Not running | Not Debuggable ``` -------------------------------- ### Install an XCTest Bundle with idb Source: https://github.com/facebook/idb/blob/main/website/docs/commands.mdx Installs a test bundle (.xctest or .xctestrun file) onto the target device, preparing it for execution. This process relocates the bundle for multiple invocation modes. ```bash idb xctest install testApp.app/Plugins/testAppTests.xctest ``` -------------------------------- ### Install idb Client with pip Source: https://github.com/facebook/idb/blob/main/website/docs/installation.mdx Installs the idb client, a CLI tool and Python library for interacting with idb. Requires Python 3.6 or greater. ```bash pip3.6 install fb-idb ``` -------------------------------- ### Start Debugserver for an App Source: https://github.com/facebook/idb/blob/main/website/docs/fbdevicecontrol.mdx Starts a debugserver for a specified application on the iOS device. The command returns bootstrapping commands required to initialize an `lldb` debugging session. ```bash # Start the debugserver, a list of bootstrapping commands are returned on stdout $ idb debugserver start com.foo.SomeApp platform select remote-ios --sysroot '/Users/Someone/Library/Developer/Xcode/iOS DeviceSupport/15.2.1 (19C63) arm64e/Symbols' target create '/private/tmp/idb-applications/com.foo.SomeApp/SomeApp.app' script lldb.target.modules[0].SetPlatformFileSpec(lldb.SBFileSpec("/private/var/containers/Bundle/Application/64B4DDB3-1049-458C-AA0B-F56AF4DCF0E0/SomeApp.app")) process connect connect://localhost:10881 ``` -------------------------------- ### Launch Safari on iPhone 6 using Swift Source: https://github.com/facebook/idb/blob/main/FBSimulatorControl/README.md This Swift script demonstrates how to initialize FBSimulatorControl, allocate and boot a specific simulator configuration (iPhone 6), and launch an installed application (Safari). Ensure the '-F' argument points to your FBSimulatorControl.framework location. ```swift #!/usr/bin/env xcrun swift -F /usr/local/Frameworks // The -F Argument should be the directory in which the FBSimulatorControl.framework is located. // Import the FBSimulatorControl Framework import FBSimulatorControl // Create the FBSimulatorControl Instance. let options = FBSimulatorManagementOptions() let config = FBSimulatorControlConfiguration(deviceSetPath: nil, options: options) let logger = FBControlCoreGlobalConfiguration.defaultLogger() let control = try FBSimulatorControl.withConfiguration(config, logger: logger) // Get an existing iPhone 6 from the Simulator Pool. let simulator = try control.pool.allocateSimulator( with: FBSimulatorConfiguration.iPhone6(), options: FBSimulatorAllocationOptions.reuse ) print("Using \(simulator)") // If it is booted, keep it booted, otherwise boot it. if (simulator.state != .booted) { print("Booting Simulator \(simulator)") try simulator.boot() } // List the Installed Apps and get the first installed app let applications = simulator.installedApplications() let application = applications.first! // Launch the first installed Application let appLaunch = FBApplicationLaunchConfiguration( application: application, arguments: [], environment: [:\], output: FBProcessOutputConfiguration.outputToDevNull() ) print("Launching \(application)") try simulator.launchApplication(appLaunch) ``` -------------------------------- ### Start idb_companion Notifier Source: https://github.com/facebook/idb/blob/main/website/docs/commands.mdx Starts the companion in notifier mode to write out changes in Device & Simulator availability. Can write to a file path or stdout. ```bash idb_companion --notify FILE_PATH|stdout ``` -------------------------------- ### Swift Function Execution Example Source: https://github.com/facebook/idb/blob/main/REPLTests/test-prompt.md This snippet demonstrates how to execute a Swift function and return its result within the idb-repl environment. Ensure no further statements follow the 'return' keyword. ```swift let result = function(10) return result ``` -------------------------------- ### Record Screen Video Source: https://github.com/facebook/idb/blob/main/website/docs/commands.mdx Starts recording the target's screen, outputting to a specified path. Press ^C to stop. ```bash idb record video OUTPUT_MP4 ``` -------------------------------- ### Check App Debuggability Source: https://github.com/facebook/idb/blob/main/website/docs/fbdevicecontrol.mdx Lists installed applications and indicates whether they are debuggable. Look for the 'Debuggable' status in the output. ```bash $ idb list-apps | grep SomeApp com.foo.SomeApp | SomeApp | user_development | no archs available | Unknown | Debuggable | pid=None ``` -------------------------------- ### idb_companion gRPC Server Source: https://github.com/facebook/idb/blob/main/website/docs/commands.mdx Commands for starting the companion gRPC server to manipulate iOS simulators and devices. ```APIDOC ## idb_companion --udid ### Description Starts a companion server for an iOS Simulator or Device. ### Method CLI ### Endpoint idb_companion --udid UDID ## idb_companion --notify ### Description Starts the companion in notifier mode to track device and simulator availability. ### Method CLI ### Endpoint idb_companion --notify FILE_PATH|stdout ``` -------------------------------- ### Start a Debug Session with idb Source: https://github.com/facebook/idb/blob/main/website/docs/commands.mdx Initiates a debug session for a given Bundle ID. The output provides connection details (e.g., connect://localhost:10881) to be used with a debugger like lldb. ```bash idb debugserver start BUNDLE_ID ``` -------------------------------- ### Execute Tests with idb Source: https://github.com/facebook/idb/blob/main/website/docs/test-execution.mdx Command to run logic tests against an installed bundle, outputting results in JSON format. ```bash $ idb xctest run logic --json com.facebook.iOSUnitTestFixture {"bundleName": "iOSUnitTestFixtureTests", "className": "iOSUnitTestFixtureTests", "methodName": "testHostProcessIsMobileSafari", "logs": [], "duration": 0.22353005409240723, "passed": false, "crashed": false, "failureInfo": {"message": "(([NSProcessInfo.processInfo.processName isEqualToString:@\"MobileSafari\"]) is true) failed", "file": "/repo_root/iOSUnitTestFixture/iOSUnitTestFixtureTests.m", "line": 50}, "activityLogs": []} {"bundleName": "iOSUnitTestFixtureTests", "className": "iOSUnitTestFixtureTests", "methodName": "testHostProcessIsXctest", "logs": [], "duration": 0.0002950429916381837, "passed": true, "crashed": false, "failureInfo": null, "activityLogs": []} {"bundleName": "iOSUnitTestFixtureTests", "className": "iOSUnitTestFixtureTests", "methodName": "testIsRunningInIOSApp", "logs": [], "duration": 0.0003999471664428711, "passed": false, "crashed": false, "failureInfo": {"message": "(([NSClassFromString(@\"UIApplication\") performSelector:@selector(sharedApplication)]) != nil) failed", "file": "/repo_root/iOSUnitTestFixture/iOSUnitTestFixtureTests.m", "line": 30}, "activityLogs": []} {"bundleName": "iOSUnitTestFixtureTests", "className": "iOSUnitTestFixtureTests", "methodName": "testIsRunningInMacOSXApp", "logs": [], "duration": 0.00030100345611572255, "passed": false, "crashed": false, "failureInfo": {"message": "(([NSClassFromString(@\"NSApplication\") performSelector:@selector(sharedApplication)]) != nil) failed", "file": "/repo_root/iOSUnitTestFixture/iOSUnitTestFixtureTests.m", "line": 40}, "activityLogs": []} {"bundleName": "iOSUnitTestFixtureTests", "className": "iOSUnitTestFixtureTests", "methodName": "testIsRunningOnIOS", "logs": [], "duration": 0.0002809762954711914, "passed": true, "crashed": false, "failureInfo": null, "activityLogs": []} {"bundleName": "iOSUnitTestFixtureTests", "className": "iOSUnitTestFixtureTests", "methodName": "testIsRunningOnMacOSX", "logs": [], "duration": 0.0003479719161987306, "passed": false, "crashed": false, "failureInfo": {"message": "((NSClassFromString(@\"NSView\")) != nil) failed", "file": "/repo_root/iOSUnitTestFixture/iOSUnitTestFixtureTests.m", "line": 35}, "activityLogs": []} {"bundleName": "iOSUnitTestFixtureTests", "className": "iOSUnitTestFixtureTests", "methodName": "testPossibleCrashingOfHostProcess", "logs": [], "duration": 0.0003750324249267579, "passed": true, "crashed": false, "failureInfo": null, "activityLogs": []} {"bundleName": "iOSUnitTestFixtureTests", "className": "iOSUnitTestFixtureTests", "methodName": "testPossibleStallingOfHostProcess", "logs": [], "duration": 0.00037300586700439453, "passed": true, "crashed": false, "failureInfo": null, "activityLogs": []} {"bundleName": "iOSUnitTestFixtureTests", "className": "iOSUnitTestFixtureTests", "methodName": "testWillAlwaysFail", "logs": [], "duration": 0.0002980232238769531, "passed": false, "crashed": false, "failureInfo": {"message": "failed - This always fails", "file": "/repo_root/iOSUnitTestFixture/iOSUnitTestFixtureTests.m", "line": 76}, "activityLogs": []} ``` -------------------------------- ### Test a Specific idb Framework Source: https://github.com/facebook/idb/blob/main/README.md Runs tests for a particular framework, for example, FBSimulatorControl. ```bash ./build.sh test FBSimulatorControl ``` -------------------------------- ### GET /ui/describe-point Source: https://github.com/facebook/idb/blob/main/website/docs/accessibility.mdx Returns the accessibility element at given co-ordinates on the iOS Simulator's screen. ```APIDOC ## GET idb ui describe-point ### Description Returns the accessibility element at given co-ordinates on the iOS Simulator's screen. This is useful for "hit test" style queries, or understanding what is under a screen pointer. ### Method GET ### Endpoint idb ui describe-point X Y ### Parameters #### Path Parameters - **X** (integer) - Required - The x-coordinate on the screen. - **Y** (integer) - Required - The y-coordinate on the screen. ### Response Example { "AXFrame": "{{199, 116}, {64, 87.5}}", "AXUniqueId": "Wallet", "frame": {"y": 116, "x": 199, "width": 64, "height": 87.5}, "role_description": "button", "AXLabel": "Wallet", "type": "Button", "enabled": true, "role": "AXButton" } ``` -------------------------------- ### Simulate a Swipe Event with idb Source: https://github.com/facebook/idb/blob/main/website/docs/commands.mdx Performs a swipe gesture from a start point (X_START, Y_START) to an end point (X_END, Y_END) on the simulator screen. The step size for the swipe can be adjusted with the --delta flag. ```bash idb ui swipe X_START Y_START X_END Y_END ``` -------------------------------- ### List Available and Mounted Disk Images Source: https://github.com/facebook/idb/blob/main/website/docs/fbdevicecontrol.mdx Lists all available Developer Disk Images within the current Xcode installation and any currently mounted images on the iOS device. This command is useful for understanding the disk image landscape before performing mount or unmount operations. ```bash # List all of the available disk images that are present within the current Xcode, as well as the current mounted image/s (if present). # No images are mounted as the "mounted" path is empty. $ idb file ls --disk-images . 15.0/DeveloperDiskImage.dmg 12.1/DeveloperDiskImage.dmg 10.0/DeveloperDiskImage.dmg 9.2/DeveloperDiskImage.dmg 9.1/DeveloperDiskImage.dmg 14.2/DeveloperDiskImage.dmg 13.4/DeveloperDiskImage.dmg 11.3/DeveloperDiskImage.dmg 13.0/DeveloperDiskImage.dmg 12.2/DeveloperDiskImage.dmg 10.1/DeveloperDiskImage.dmg 13.1/DeveloperDiskImage.dmg 11.0/DeveloperDiskImage.dmg 14.3/DeveloperDiskImage.dmg 13.5/DeveloperDiskImage.dmg 11.4/DeveloperDiskImage.dmg 12.3/DeveloperDiskImage.dmg 10.2/DeveloperDiskImage.dmg 14.0/DeveloperDiskImage.dmg 13.2/DeveloperDiskImage.dmg 11.1/DeveloperDiskImage.dmg 14.4/DeveloperDiskImage.dmg 13.6/DeveloperDiskImage.dmg 12.0/DeveloperDiskImage.dmg 14.5/DeveloperDiskImage.dmg 12.4/DeveloperDiskImage.dmg 10.3/DeveloperDiskImage.dmg 14.1/DeveloperDiskImage.dmg 11.2/DeveloperDiskImage.dmg 13.3/DeveloperDiskImage.dmg 9.0/DeveloperDiskImage.dmg 9.3/DeveloperDiskImage.dmg 13.7/DeveloperDiskImage.dmg $ idb file ls --disk-images mounted ``` -------------------------------- ### Boot a Simulator/Device Source: https://github.com/facebook/idb/blob/main/website/docs/guided-tour.mdx Initiates a simulator or device. Replace 'UDID' with the actual unique identifier of the target. ```bash idb boot UDID ``` -------------------------------- ### Bootstrap Application with lldb Source: https://github.com/facebook/idb/blob/main/website/docs/fbdevicecontrol.mdx Use these lldb commands to select the remote platform, create the target executable, set its platform file specification, connect to the debugserver, and run the application. Ensure the debugserver is running and accessible. ```bash # Start lldb and pass the bootrapping commands from above $ lldb (lldb) platform select remote-ios --sysroot '/Users/Someone/Library/Developer/Xcode/iOS DeviceSupport/15.2.1 (19C63) arm64e/Symbols' Platform: remote-ios Connected: no SDK Path: "/Users/Someone/Library/Developer/Xcode/iOS DeviceSupport/15.2.1 (19C63) arm64e/Symbols" (lldb) target create '/private/tmp/idb-applications/com.foo.SomeApp/SomeApp.app' script lldb.target.modules[0].SetPlatformFileSpec(lldb.SBFileSpec("/private/var/containers/Bundle/Application/64B4DDB3-1049-458C-AA0B-F56AF4DCF0E0/SomeApp.app"))Current executable set to '/private/tmp/idb-applications/com.foo.SomeApp/SomeApp.app' (arm64). (lldb) script lldb.target.modules[0].SetPlatformFileSpec(lldb.SBFileSpec("/private/var/containers/Bundle/Application/64B4DDB3-1049-458C-AA0B-F56AF4DCF0E0/SomeApp.app")) True (lldb) process connect connect://localhost:10881 (lldb) r Process 10416 launched: '/private/tmp/idb-applications/com.foo.SomeApp/SomeApp.app/SomeApp' (arm64) ``` -------------------------------- ### idb Build Script Help Source: https://github.com/facebook/idb/blob/main/README.md Displays all available options and commands for the idb build script. ```bash ./build.sh help ``` -------------------------------- ### Build idb_companion Source: https://github.com/facebook/idb/blob/main/website/docs/development.mdx Build the idb_companion and its associated frameworks and helpers using the provided build script. ```bash ./build.sh build ``` -------------------------------- ### Debug Session Management Source: https://github.com/facebook/idb/blob/main/website/docs/commands.mdx Commands for starting, stopping, and checking the status of debug sessions. ```APIDOC ## Starting a debug session ### Description Starts a debug session for a given application bundle ID. ### Method `idb debugserver start` ### Endpoint `idb debugserver start [BUNDLE_ID]` ### Parameters #### Path Parameters - **BUNDLE_ID** (string) - Required - The bundle identifier of the app to debug. ### Request Example ``` idb debugserver start com.example.MyApp ``` ### Response Example ``` process connect connect://localhost:10881 ``` ## Stop a debug session ### Description Stops a currently running debug session. ### Method `idb debugserver stop` ### Endpoint `idb debugserver stop` ### Request Example ``` idb debugserver stop ``` ## Information about a debug session ### Description Displays metadata about any active debug sessions. ### Method `idb debugserver status` ### Endpoint `idb debugserver status` ### Request Example ``` idb debugserver status ``` ``` -------------------------------- ### List Available Targets Source: https://github.com/facebook/idb/blob/main/website/docs/guided-tour.mdx Use this command to discover all available simulators and attached devices on your Mac. ```bash idb list-targets ``` -------------------------------- ### Run idb_companion Source: https://github.com/facebook/idb/blob/main/website/docs/development.mdx Execute the idb_companion directly from the distribution directory, specifying the target UDID. ```bash ./Build/Distribution/idb_companion --udid ``` -------------------------------- ### Get Debug Session Status with idb Source: https://github.com/facebook/idb/blob/main/website/docs/commands.mdx Displays metadata regarding any currently running debug sessions. ```bash idb debugserver status ``` -------------------------------- ### Boot an iOS simulator Source: https://github.com/facebook/idb/blob/main/website/docs/commands.mdx Boot a specific iOS simulator using its UDID. This command is only applicable to simulators. ```bash idb --boot UDID ``` -------------------------------- ### Launch an Application on a Target Source: https://github.com/facebook/idb/blob/main/README.md Launches a specified application on a target simulator or device using its bundle ID. ```bash $ idb launch com.apple.mobilesafari ``` -------------------------------- ### Terminate a Running App with idb Source: https://github.com/facebook/idb/blob/main/website/docs/commands.mdx Kills a running application identified by its Bundle ID. This command will fail if the app is not running or not installed. ```bash idb terminate com.apple.Maps ``` -------------------------------- ### Build a Specific idb Framework Source: https://github.com/facebook/idb/blob/main/README.md Builds a single specified framework, such as FBControlCore. ```bash ./build.sh build FBControlCore ``` -------------------------------- ### Build SimulatorFrameworkBridge Source: https://github.com/facebook/idb/blob/main/README.md Builds the SimulatorFrameworkBridge helper utility. ```bash ./build.sh build SimulatorFrameworkBridge ``` -------------------------------- ### Stream Video to FFmpeg via UDP Source: https://github.com/facebook/idb/blob/main/website/docs/video.mdx Stream video from an iOS device and pipe it to ffmpeg for real-time processing and network exposure. Ensure ffmpeg is installed and accessible in your PATH. ```bash $ idb video-stream --fps 30 --format h264 --compression-quality 1.0 --udid EE074DCE-7D75-4F96-A949-82252F5FEC30 | ffmpeg -f h264 -i pipe:0 -vcodec copy -tune zerolatency -b 900k -framerate 30 -f mpegts udp://0.0.0.0:12345 ``` -------------------------------- ### Launch an App with idb Source: https://github.com/facebook/idb/blob/main/website/docs/commands.mdx Launches an application on the target device. Environment variables prefixed with IDB_ are set on the app, and custom launch arguments can be appended. Use -f/--foreground-if-running to keep the app running if it's already active, and -w/--wait-for to stream stdout/stderr until the app exits. ```bash idb launch com.apple.Maps ``` -------------------------------- ### Describe All Elements on Screen with idb Source: https://github.com/facebook/idb/blob/main/website/docs/commands.mdx Retrieves a JSON-formatted list of all elements currently visible on the simulator screen, including their bounds and accessibility details. ```bash idb ui describe-all ``` -------------------------------- ### Build idb_companion Only Source: https://github.com/facebook/idb/blob/main/README.md Builds only the idb_companion executable. ```bash ./build.sh build idb_companion ``` -------------------------------- ### Mount a Specific Developer Disk Image Source: https://github.com/facebook/idb/blob/main/website/docs/fbdevicecontrol.mdx Mounts a specified Developer Disk Image (e.g., for iOS 15.0) onto the attached iOS device. This operation requires the disk image to be present in the Xcode installation and is necessary to enable certain device functionalities. ```bash # Mounting for the current iOS Version of the attached device (iOS 15.0 succeeds). $ idb file mv --disk-images 15.0/DeveloperDiskImage.dmg mounted ``` -------------------------------- ### Configure idb CLI to use Companion Source: https://github.com/facebook/idb/blob/main/website/docs/development.mdx Set the IDB_COMPANION environment variable to connect the idb CLI to a running companion instance. ```bash $ IDB_COMPANION=localhost:10882 idb describe ``` -------------------------------- ### Create a new directory Source: https://github.com/facebook/idb/blob/main/website/docs/file-containers.mdx Creates a new folder within the specified application data container. ```bash idb file mkdir --application com.foo.bar/newdir ``` -------------------------------- ### App Management Source: https://github.com/facebook/idb/blob/main/website/docs/commands.mdx Commands for launching, terminating, and uninstalling applications. ```APIDOC ## Launch an app ### Description Launches an application on the target device or simulator. Environment variables prefixed with `IDB_` are set on the app, and custom launch arguments can be appended. ### Method `idb launch` ### Endpoint `idb launch [BUNDLE_ID] [--foreground-if-running | -f] [--wait-for | -w]` ### Parameters #### Path Parameters - **BUNDLE_ID** (string) - Required - The bundle identifier of the app to launch. #### Query Parameters - **-f, --foreground-if-running** - Optional - If the app is already running, bring it to the foreground instead of failing. - **-w, --wait-for** - Optional - Stream the stdout and stderr of the launched process until it exits. The app will be killed when `SIGTERM` is sent to the `idb` CLI. ### Request Example ``` idb launch com.apple.Maps ``` ## Kill a running app ### Description Terminates a running application on the target device or simulator. ### Method `idb terminate` ### Endpoint `idb terminate [BUNDLE_ID]` ### Parameters #### Path Parameters - **BUNDLE_ID** (string) - Required - The bundle identifier of the app to terminate. ### Request Example ``` idb terminate com.apple.Maps ``` ## Uninstalling an app ### Description Removes an application from the target device or simulator. ### Method `idb uninstall` ### Endpoint `idb uninstall [BUNDLE_ID]` ### Parameters #### Path Parameters - **BUNDLE_ID** (string) - Required - The bundle identifier of the app to uninstall. ### Request Example ``` idb uninstall com.foo.bar ``` ``` -------------------------------- ### Miscellaneous Utilities Source: https://github.com/facebook/idb/blob/main/website/docs/commands.mdx Utility commands for managing the idb environment and simulator. ```APIDOC ## Reset Idb ### Description Clears local idb companion files and stops the idb notifier if it is running. ### Method `idb kill` ### Endpoint `idb kill` ### Request Example ``` idb kill ``` ## Focus a simulator's window ### Description Brings the simulator's window to the foreground. ### Method `idb focus` ### Endpoint `idb focus` ### Request Example ``` idb focus ``` ## Install a .dylib ### Description Installs a `.dylib` file onto the target, which can then be injected into apps on launch. ### Method `idb dylib install` ### Endpoint `idb dylib install [PATH_TO_DYLIB]` ### Parameters #### Path Parameters - **PATH_TO_DYLIB** (string) - Required - The path to the `.dylib` file to install. ### Request Example ``` idb dylib install ./my_library.dylib ``` ``` -------------------------------- ### POST /ui/button Source: https://github.com/facebook/idb/blob/main/website/docs/accessibility.mdx Simulates a button press on the iOS Simulator. ```APIDOC ## POST idb button ### Description Simulates a button press on the iOS Simulator. ### Method POST ### Endpoint idb button BUTTON_NAME ### Parameters #### Path Parameters - **BUTTON_NAME** (string) - Required - The name of the button to press (e.g., APPLE_PAY, HOME, LOCK, SIDE_BUTTON, SIRI). ``` -------------------------------- ### Focus Simulator Window with idb Source: https://github.com/facebook/idb/blob/main/website/docs/commands.mdx Brings the simulator's window to the foreground, making it the active application. ```bash idb focus ``` -------------------------------- ### POST /text Source: https://github.com/facebook/idb/blob/main/website/docs/accessibility.mdx Sends keyboard events to the iOS Simulator. ```APIDOC ## POST idb text ### Description Sends keyboard events to the iOS Simulator. This can be used at any time and are equivalent to sending events via a hardware keyboard. ### Method POST ### Endpoint idb text 'TEXT_CONTENT' ### Parameters #### Path Parameters - **TEXT_CONTENT** (string) - Required - The text string to send to the simulator. ``` -------------------------------- ### Describe iOS Simulator UI hierarchy Source: https://github.com/facebook/idb/blob/main/website/docs/accessibility.mdx Executes the command to retrieve the UI hierarchy of the iOS Simulator as a JSON array. ```bash idb ui describe-all [{"AXFrame":"{{0, 0}, {375, 667}}","AXUniqueId":null,"frame":{"y":0,"x":0,"width":375,"height":667},"role_description":"application","AXLabel":" ","content_required":false,"type":"Application","title":null,"help":null,"custom_actions":[],"AXValue":null,"enabled":true,"role":"AXApplication","subrole":null},{"AXFrame":"{{0, 0}, {375, 667}}","AXUniqueId":null,"frame":{"y":0,"x":0,"width":375,"height":667},"role_description":"group","AXLabel":null,"content_required":false,"type":"Group","title":null,"help":null,"custom_actions":[],"AXValue":null,"enabled":true,"role":"AXGroup","subrole":null},{"AXFrame":"{{21.5, 28}, {72, 87.5}}","AXUniqueId":"Calendar","frame":{"y":28,"x":21.5,"width":72,"height":87.5},"role_description":"button","AXLabel":"Calendar","content_required":false,"type":"Button","title":null,"help":null,"custom_actions":["Edit mode","Today"],"AXValue":"Wednesday, October 14","enabled":true,"role":"AXButton","subrole":null},{"AXFrame":"{{112, 28}, {64, 87.5}}","AXUniqueId":"Photos","frame":{"y":28,"x":112,"width":64,"height":87.5},"role_description":"button","AXLabel":"Photos","content_required":false,"type":"Button","title":null,"help":null,"custom_actions":["Edit mode","Today"],"AXValue":"","enabled":true,"role":"AXButton","subrole":null},{"AXFrame":"{{199, 28}, {64, 87.5}}","AXUniqueId":"Maps","frame":{"y":28,"x":199,"width":64,"height":87.5},"role_description":"button","AXLabel":"Maps","content_required":false,"type":"Button","title":null,"help":null,"custom_actions":["Edit mode","Today"],"AXValue":"","enabled":true,"role":"AXButton","subrole":null},{"AXFrame":"{{277.5, 28}, {81.5, 87.5}}","AXUniqueId":"Reminders","frame":{"y":28,"x":277.5,"width":81.5,"height":87.5},"role_description":"button","AXLabel":"Reminders","content_required":false,"type":"Button","title":null,"help":null,"custom_actions":["Edit mode","Today"],"AXValue":"","enabled":true,"role":"AXButton","subrole":null},{"AXFrame":"{{25, 116}, {64, 87.5}}","AXUniqueId":"News","frame":{"y":116,"x":25,"width":64,"height":87.5},"role_description":"button","AXLabel":"News","content_required":false,"type":"Button","title":null,"help":null,"custom_actions":["Edit mode","Today"],"AXValue":"","enabled":true,"role":"AXButton","subrole":null},{"AXFrame":"{{112, 116}, {64, 87.5}}","AXUniqueId":"Health","frame":{"y":116,"x":112,"width":64,"height":87.5},"role_description":"button","AXLabel":"Health","content_required":false,"type":"Button","title":null,"help":null,"custom_actions":["Edit mode","Today"],"AXValue":"","enabled":true,"role":"AXButton","subrole":null},{"AXFrame":"{{199, 116}, {64, 87.5}}","AXUniqueId":"Wallet","frame":{"y":116,"x":199,"width":64,"height":87.5},"role_description":"button","AXLabel":"Wallet","content_required":false,"type":"Button","title":null,"help":null,"custom_actions":["Edit mode","Today"],"AXValue":"","enabled":true,"role":"AXButton","subrole":null},{"AXFrame":"{{284, 116}, {68.5, 87.5}}","AXUniqueId":"Settings","frame":{"y":116,"x":284,"width":68.5,"height":87.5},"role_description":"button","AXLabel":"Settings","content_required":false,"type":"Button","title":null,"help":null,"custom_actions":["Edit mode","Today"],"AXValue":"","enabled":true,"role":"AXButton","subrole":null},{"AXFrame":"{{146, 546.5}, {83.5, 25}}","AXUniqueId":"Page control","frame":{"y":546.5,"x":146,"width":83.5,"height":25},"role_description":"slider","AXLabel":null,"content_required":false,"type":"Slider","title":null,"help":null,"custom_actions":[],"AXValue":"Page 1 of 2","enabled":true,"role":"AXSlider","subrole":null},{"AXFrame":"{{0, 575}, {375, 92}}","AXUniqueId":null,"frame":{"y":575,"x":0,"width":375,"height":92},"role_description":"group","AXLabel":"Dock","content_required":false,"type":"Group","title":null,"help":null,"custom_actions":[],"AXValue":null,"enabled":true,"role":"AXGroup","subrole":null},{"AXFrame":"{{112, 589}, {64, 64}}","AXUniqueId":"Safari","frame":{"y":589,"x":112,"width":64,"height":64},"role_description":"button","AXLabel":"Safari","content_required":false,"type":"Button","title":null,"help":null,"custom_actions":["Edit mode","Today"],"AXValue":"","enabled":true,"role":"AXButton","subrole":null},{"AXFrame":"{{199, 589}, {64, 64}}","AXUniqueId":"Messages","frame":{"y":589,"x":199,"width":64,"height":64},"role_description":"button","AXLabel":"Messages","content_required":false,"type":"Button","title":null,"help":null,"custom_actions":["Edit mode","Today"],"AXValue":"","enabled":true,"role":"AXButton","subrole":null}] ``` -------------------------------- ### Build idb Frameworks Only Source: https://github.com/facebook/idb/blob/main/README.md Builds only the frameworks required by idb. ```bash ./build.sh build frameworks ``` -------------------------------- ### Assemble idb Distribution Source: https://github.com/facebook/idb/blob/main/README.md Assembles the self-contained distribution package from the built products, organized for idb_companion's runtime requirements. ```bash ./build.sh build distribution ``` -------------------------------- ### Build idb Shim Dylibs Source: https://github.com/facebook/idb/blob/main/README.md Builds the shim dynamic libraries for both iOS and macOS, including Shimulator and Repl. ```bash ./build.sh build shims ``` -------------------------------- ### Permissions and Data Management Source: https://github.com/facebook/idb/blob/main/website/docs/commands.mdx Commands for managing simulator permissions, keychain, and contact databases. ```APIDOC ## idb clear_keychain ### Description Clears the entire keychain for simulators. ### Method CLI ### Endpoint idb clear_keychain ## idb approve ### Description Programmatically approve permissions for an app (photos, camera, contacts). ### Method CLI ### Endpoint idb approve BUNDLE_ID PERMISSION ## idb contacts update ### Description Overwrites the simulator's contacts database. ### Method CLI ### Endpoint idb contacts update DB_PATH ``` -------------------------------- ### UI Interaction Source: https://github.com/facebook/idb/blob/main/website/docs/commands.mdx Commands for simulating user interactions on the simulator. ```APIDOC ## Tap ### Description Simulates a tap at a specific coordinate on the screen. ### Method `idb ui tap` ### Endpoint `idb ui tap X Y [--duration DURATION]` ### Parameters #### Path Parameters - **X** (integer) - Required - The X-coordinate of the tap. - **Y** (integer) - Required - The Y-coordinate of the tap. #### Query Parameters - **--duration DURATION** (float) - Optional - The duration of the tap in seconds. ### Request Example ``` idb ui tap 100 200 --duration 0.5 ``` ## Swipe ### Description Simulates a swipe gesture between two points on the screen. ### Method `idb ui swipe` ### Endpoint `idb ui swipe X_START Y_START X_END Y_END [--delta DELTA]` ### Parameters #### Path Parameters - **X_START** (integer) - Required - The starting X-coordinate of the swipe. - **Y_START** (integer) - Required - The starting Y-coordinate of the swipe. - **X_END** (integer) - Required - The ending X-coordinate of the swipe. - **Y_END** (integer) - Required - The ending Y-coordinate of the swipe. #### Query Parameters - **--delta DELTA** (integer) - Optional - The size of each step in points during the swipe. Defaults to 10. ### Request Example ``` idb ui swipe 100 100 300 300 --delta 20 ``` ## Press a button ### Description Simulates a press of a specific hardware button. ### Method `idb ui button` ### Endpoint `idb ui button {APPLE_PAY,HOME,LOCK,SIDE_BUTTON,SIRI} [--duration DURATION]` ### Parameters #### Path Parameters - **BUTTON_TYPE** (enum) - Required - The type of button to press (e.g., `HOME`, `LOCK`). #### Query Parameters - **--duration DURATION** (float) - Optional - The duration of the button press in seconds. ### Request Example ``` idb ui button HOME --duration 1.0 ``` ## Inputting text ### Description Types the specified text into the target application. ### Method `idb ui text` ### Endpoint `idb ui text "[TEXT]"` ### Parameters #### Path Parameters - **TEXT** (string) - Required - The text to input. ### Request Example ``` idb ui text "Hello, World!" ``` ## Inputting key events ### Description Simulates the press of a key specified by its keycode. ### Method `idb ui key` ### Endpoint `idb ui key [KEYCODE] [--duration DURATION]` ### Parameters #### Path Parameters - **KEYCODE** (integer) - Required - The keycode of the key to press. #### Query Parameters - **--duration DURATION** (float) - Optional - The duration of the key press in seconds. ### Request Example ``` idb ui key 4 --duration 0.2 ``` ## Inputting multiple key events ### Description Inputs multiple key events sequentially. ### Method `idb ui key-sequence` ### Endpoint `idb ui key-sequence [KEYCODE1] [KEYCODE2] ... [--duration DURATION]` ### Parameters #### Path Parameters - **KEYCODE1, KEYCODE2, ...** (integer) - Required - The keycodes of the keys to press in sequence. #### Query Parameters - **--duration DURATION** (float) - Optional - The duration of each key press in seconds. ### Request Example ``` idb ui key-sequence 4 5 6 ``` ``` -------------------------------- ### Open URL on Target Source: https://github.com/facebook/idb/blob/main/website/docs/commands.mdx Opens the specified URL on the target, supporting web addresses and URL schemes. ```bash idb open https://facebook.com ``` -------------------------------- ### Describe UI element at coordinates Source: https://github.com/facebook/idb/blob/main/website/docs/accessibility.mdx Returns accessibility information for the element located at the specified X and Y coordinates. ```bash idb ui describe-point 200 200 {"AXFrame":"{{199, 116}, {64, 87.5}}","AXUniqueId":"Wallet","frame":{"y":116,"x":199,"width":64,"height":87.5},"role_description":"button","AXLabel":"Wallet","content_required":false,"type":"Button","title":null,"help":null,"custom_actions":["Edit mode","Today"],"AXValue":"","enabled":true,"role":"AXButton","subrole":null} ``` -------------------------------- ### List files in a path Source: https://github.com/facebook/idb/blob/main/website/docs/file-containers.mdx Returns a list of all files present within one or more directories on the target. ```bash idb file ls --application com.foo.bar/Caches ``` -------------------------------- ### Run command against a specific companion Source: https://github.com/facebook/idb/blob/main/website/docs/commands.mdx Prefix any idb command with the IDB_COMPANION environment variable to target a specific companion. This is useful when the companion's address (TCP or domain socket) is known. ```bash # Run a describe command against a companion running on the loopback interface # on TCP Port 10882 $ IDB_COMPANION=localhost:10882 idb describe # This can also be a path to a domain socket that the companion is running on $ IDB_COMPANION=/tmp/idb_companion_domain_sock idb describe ``` -------------------------------- ### Approve Permissions on Simulator Source: https://github.com/facebook/idb/blob/main/website/docs/commands.mdx Programmatically approves permissions for an app on simulators. Supports photos, camera, and contacts. ```bash idb approve com.apple.Maps photos camera ``` -------------------------------- ### Input Text with idb Source: https://github.com/facebook/idb/blob/main/website/docs/commands.mdx Types the specified text into the active input field on the simulator. ```bash idb ui text "some text" ``` -------------------------------- ### Describe Element at a Point with idb Source: https://github.com/facebook/idb/blob/main/website/docs/commands.mdx Returns JSON-formatted information about the specific element located at the given screen coordinates (X, Y). ```bash idb ui describe-point X Y ``` -------------------------------- ### Target Management Commands Source: https://github.com/facebook/idb/blob/main/website/docs/commands.mdx Commands for interacting with the target device or simulator, such as recording video, managing media, and setting location. ```APIDOC ## idb instruments ### Description Starts instruments running connected to the target. ### Method CLI ### Endpoint idb instruments TEMPLATE ## idb record video ### Description Starts recording the target's screen, outputting the content to the specified path. ### Method CLI ### Endpoint idb record video OUTPUT_MP4 ## idb open ### Description Opens the specified URL on the target. Works with web addresses and URL schemes. ### Method CLI ### Endpoint idb open URL ## idb set_location ### Description Overrides a simulator's location to the latitude, longitude pair specified. ### Method CLI ### Endpoint idb set_location LAT LONG ## idb add-media ### Description Places files into the target's camera roll. ### Method CLI ### Endpoint idb add-media FILE_PATHS ``` -------------------------------- ### Tap screen coordinates Source: https://github.com/facebook/idb/blob/main/website/docs/accessibility.mdx Simulates a tap event at the provided X and Y coordinates on the simulator screen. ```bash idb ui tap 200 200 ``` -------------------------------- ### Simulate Multiple Key Presses with idb Source: https://github.com/facebook/idb/blob/main/website/docs/commands.mdx Inputs a sequence of key events by specifying their keycodes. ```bash idb ui key-sequence 4 5 6 ``` -------------------------------- ### Test Execution Source: https://github.com/facebook/idb/blob/main/website/docs/commands.mdx Commands for managing and running XCTest bundles. ```APIDOC ## Install a test bundle ### Description Installs a test bundle (`.xctest` or `.xctestrun` file) onto the target device or simulator, preparing it for execution. ### Method `idb xctest install` ### Endpoint `idb xctest install [PATH_TO_TEST_BUNDLE]` ### Parameters #### Path Parameters - **PATH_TO_TEST_BUNDLE** (string) - Required - The path to the `.xctest` or `.xctestrun` file. ### Request Example ``` idb xctest install testApp.app/Plugins/testAppTests.xctest ``` ## List installed tests ### Description Lists all test bundles that have been installed on the target. ### Method `idb xctest list` ### Endpoint `idb xctest list` ### Request Example ``` idb xctest list ``` ## List tests inside a bundle ### Description Lists all individual tests contained within a specified test bundle. ### Method `idb xctest list-bundle` ### Endpoint `idb xctest list-bundle [BUNDLE_ID]` ### Parameters #### Path Parameters - **BUNDLE_ID** (string) - Required - The bundle identifier of the test bundle. ### Request Example ``` idb xctest list-bundle com.facebook.myAppTests ``` ## Running tests ### Description Executes tests on the target. Environment variables prefixed with `IDB_` and arguments appended to the command are passed to the test run. ### Method `idb xctest run` ### Endpoint `idb xctest run [OPTIONS] [ARGUMENTS...]` ### Parameters #### Query Parameters - **Environment Variables**: Variables prefixed with `IDB_` will be passed to the test run with the prefix removed. - **Arguments**: Any arguments appended to the command will be supplied to the test run. ### Request Example ``` idb xctest run --runner-class MyRunner --test-case MyTestCase ``` ``` -------------------------------- ### List Tests within a Bundle with idb Source: https://github.com/facebook/idb/blob/main/website/docs/commands.mdx Lists all individual tests contained within a specified test bundle by loading it in the target's runtime. ```bash idb xctest list-bundle com.facebook.myAppTests ```