node-simctl

中文文档
9.1.2发布于 2026/11/04Apache-2.0TypeScriptES Module构建来源已验证

Wrapper around Apple's simctl binary

原始使用文档
文档目录5 节
  1. node-simctl
  2. Installation
  3. API
  4. Advanced Usage
  5. Running Multiple Simulator SDKs On a Single Computer

node-simctl

NPM version Downloads

Release

ES6/7 Node wrapper around Apple's simctl binary, the "Command line utility to control the iOS Simulator". simctl is run as a sub-command of xcrun

Installation

Install through npm.

npm install node-simctl

API

The module exports single class Simctl. This class contains methods which wrap the following simctl subcommands:

create (Create a new device)

  • createDevice *

clone (Clone an existing device)

None

upgrade (Upgrade a device to a newer runtime)

None

delete (Delete specified devices, unavailable devices, or all devices)

  • deleteDevice

pair (Create a new watch and phone pair)

None

unpair (Unpair a watch and phone pair)

None

pair_activate (Set a given pair as active)

None

erase (Erase a device's contents and settings)

  • eraseDevice

boot (Boot a device)

  • bootDevice

shutdown (Shutdown a device)

  • shutdownDevice

rename (Rename a device)

None

getenv (Print an environment variable from a running device)

  • getEnv

openurl (Open a URL in a device)

  • openUrl

addmedia (Add photos, live photos, videos, or contacts to the library of a device)

  • addMedia

install (Install an app on a device)

  • installApp

uninstall (Uninstall an app from a device)

  • uninstallApp

get_app_container (Print the path of the installed app's container)

  • getAppContainer

launch (Launch an application by identifier on a device)

  • launchApp

terminate (Terminate an application by identifier on a device)

  • terminateApp

spawn (Spawn a process by executing a given executable on a device)

  • spawnProcess
  • spawnSubProcess

list (List available devices, device types, runtimes, or device pairs)

  • getDevicesByParsing *
  • getDevices *
  • getRuntimeForPlatformVersionViaJson *
  • getRuntimeForPlatformVersion *
  • getDeviceTypes *
  • list *

icloud_sync (Trigger iCloud sync on a device)

None

pbsync (Sync the pasteboard content from one pasteboard to another)

None

pbcopy (Copy standard input onto the device pasteboard)

  • setPasteboard

pbpaste (Print the contents of the device's pasteboard to standard output)

  • getPasteboard

help (Prints the usage for a given subcommand)

None

io (Set up a device IO operation)

  • getScreeenshot

diagnose (Collect diagnostic information and logs)

None

logverbose (enable or disable verbose logging for a device)

None

status_bar (Set or clear status bar overrides)

None

ui (Get or Set UI options)

  • getAppearance
  • setAppearance

push (Send a simulated push notification)

  • pushNotification

privacy (Grant, revoke, or reset privacy and permissions)

  • grantPermission
  • revokePermission
  • resetPermission

keychain (Manipulate a device's keychain)

  • addRootCertificate
  • addCertificate
  • resetKeychain

appinfo (Undocumented)

  • appInfo

bootstatus (Undocumented)

  • startBootMonitor

Methods marked with the star (*) character do not require the udid property to be set on the Simctl instance upon their invocation. All other methods will throw an error if the udid property is unset while they are being invoked.

All public methods are supplied with docstrings that describe their arguments and returned values.

The Simctl class constructor supports the following options:

  • xcrun (Object): The xcrun properties. Currently only one property is supported, which is path and it by default contains null, which enforces the instance to automatically detect the full path to xcrun tool and to throw an exception if it cannot be detected. If the path is set upon instance creation then it is going to be used by exec and no autodetection will happen.
  • execTimeout (number[600000]): The maximum number of milliseconds to wait for a single synchronous xcrun command.
  • logErrors (boolean[true]): Whether to write xcrun error messages into the debug log before throwing them as errors.
  • udid (string[null]): The unique identifier of the current device, which is going to be implicitly passed to all methods, which require it (see above). It can either be set upon instance creation if it is already known or later when/if needed via the corresponding setter.
  • devicesSetPath (string[null]): Full path to the set of devices that you want to manage. By default this path usually equals to ~/Library/Developer/CoreSimulator/Devices. This option has a getter and a setter which allows to switch between multiple device sets during the Simctl instance life cycle.

Advanced Usage

Any simctl subcommand could be called via exec method, which accepts the subcommand itself as the first argument and the set of options, which may contain additional command args, environment variables, encoding, etc. For example:

import Simctl from 'node-simctl';

const simctl = new Simctl();
const name = 'My Device Name';
simctl.udid = await simctl.createDevice(name, 'iPhone X', '13.3');
await simctl.bootDevice();
await simctl.startBootMonitor({timeout: 120000});
await simctl.exec('pbsync');
console.log(`Pasteboard content: ${await simctl.getPasteboard()}`);
const {stdout} = await simctl.exec('status_bar', {
  args: [simctl.udid, 'list']
});
console.log(output);
simctl.udid = void(await simctl.deleteDevice());

See specs for examples of usage.

Running Multiple Simulator SDKs On a Single Computer

It is possible to run multiple simulators using different Xcode SDKs on a single machine. Simply set a proper value to DEVELOPER_DIR environment variable for each process.

Read this MacOps article for more details.

版本与发布记录

node-simctl 共发布 183 个版本,首次发布于 2014/12/05;过去 12 个月发布了 26 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
9.1.2latest2026/11/04今天
9.1.12026/07/273 个月前
9.1.02026/07/263 个月前
9.0.02026/07/253 个月前
8.2.92026/07/153 个月前
8.2.82026/07/064 个月前

关于 node-simctl 的常见问题

node-simctl 是什么?

Wrapper around Apple's simctl binary

如何安装 node-simctl?

在项目目录运行 npm install node-simctl,或使用 pnpm add / yarn add / bun add。

node-simctl 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

node-simctl 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

node-simctl 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js ^20.19.0 || ^22.12.0 || >=24.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

node-simctl 可以商用吗?

node-simctl 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

node-simctl 还在维护吗?

最新版本 9.1.2 发布于 2026/11/04(今天);至今共发布 183 个版本,其中过去 12 个月发布了 26 个;首次发布于 2014/12/05。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。