@mcesystems/apple-kit 1.0.24 → 1.0.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. package/README.md +284 -250
  2. package/dist/index.js +156 -22
  3. package/dist/index.js.map +3 -3
  4. package/dist/index.mjs +156 -24
  5. package/dist/index.mjs.map +3 -3
  6. package/dist/resources/bin/darwin/idevice_id +0 -0
  7. package/dist/resources/bin/darwin/idevicedebug +0 -0
  8. package/dist/resources/bin/darwin/idevicediagnostics +0 -0
  9. package/dist/resources/bin/darwin/ideviceinfo +0 -0
  10. package/dist/resources/bin/darwin/ideviceinstaller +0 -0
  11. package/dist/resources/bin/darwin/idevicename +0 -0
  12. package/dist/resources/bin/darwin/idevicepair +0 -0
  13. package/dist/resources/bin/darwin/idevicescreenshot +0 -0
  14. package/dist/resources/bin/darwin/idevicesyslog +0 -0
  15. package/dist/resources/bin/darwin/iproxy +0 -0
  16. package/dist/resources/bin/darwin/libcrypto.3.dylib +0 -0
  17. package/dist/resources/bin/darwin/libimobiledevice-1.0.6.dylib +0 -0
  18. package/dist/resources/bin/darwin/libimobiledevice-glue-1.0.0.dylib +0 -0
  19. package/dist/resources/bin/darwin/liblzma.5.dylib +0 -0
  20. package/dist/resources/bin/darwin/libplist-2.0.4.dylib +0 -0
  21. package/dist/resources/bin/darwin/libssl.3.dylib +0 -0
  22. package/dist/resources/bin/darwin/libusbmuxd-2.0.7.dylib +0 -0
  23. package/dist/resources/bin/darwin/libzip.5.dylib +0 -0
  24. package/dist/resources/bin/darwin/libzstd.1.dylib +0 -0
  25. package/{resources → dist/resources}/licenses/LGPL-2.1.txt +33 -33
  26. package/dist/types/logic/actions/device.d.ts.map +1 -1
  27. package/dist/types/logic/actions/proxy.d.ts.map +1 -1
  28. package/dist/types/logic/appleDeviceKit.d.ts +1 -1
  29. package/dist/types/logic/appleDeviceKit.d.ts.map +1 -1
  30. package/package.json +7 -4
  31. package/scripts/README.md +209 -0
  32. package/scripts/build-windows.sh.template +134 -0
  33. package/scripts/export-resources.ts +444 -0
  34. package/dist/types/utils/portManager.d.ts +0 -68
  35. package/dist/types/utils/portManager.d.ts.map +0 -1
  36. package/resources/bin/windows/bz2.dll +0 -0
  37. package/resources/bin/windows/getopt.dll +0 -0
  38. package/resources/bin/windows/iconv-2.dll +0 -0
  39. package/resources/bin/windows/idevice_id.exe +0 -0
  40. package/resources/bin/windows/ideviceactivation.exe +0 -0
  41. package/resources/bin/windows/idevicedebug.exe +0 -0
  42. package/resources/bin/windows/ideviceinfo.exe +0 -0
  43. package/resources/bin/windows/ideviceinstaller.exe +0 -0
  44. package/resources/bin/windows/idevicepair.exe +0 -0
  45. package/resources/bin/windows/imobiledevice.dll +0 -0
  46. package/resources/bin/windows/iproxy.exe +0 -0
  47. package/resources/bin/windows/libcrypto-1_1-x64.dll +0 -0
  48. package/resources/bin/windows/libcurl.dll +0 -0
  49. package/resources/bin/windows/libideviceactivation-1.0.dll +0 -0
  50. package/resources/bin/windows/libimobiledevice-1.0.dll +0 -0
  51. package/resources/bin/windows/libimobiledevice-glue-1.0.dll +0 -0
  52. package/resources/bin/windows/libplist-2.0.dll +0 -0
  53. package/resources/bin/windows/libssl-1_1-x64.dll +0 -0
  54. package/resources/bin/windows/libusb-1.0.dll +0 -0
  55. package/resources/bin/windows/libusb0.dll +0 -0
  56. package/resources/bin/windows/libusbmuxd-2.0.dll +0 -0
  57. package/resources/bin/windows/libxml2.dll +0 -0
  58. package/resources/bin/windows/lzma.dll +0 -0
  59. package/resources/bin/windows/pcre.dll +0 -0
  60. package/resources/bin/windows/pcreposix.dll +0 -0
  61. package/resources/bin/windows/plist.dll +0 -0
  62. package/resources/bin/windows/pthreadVC3.dll +0 -0
  63. package/resources/bin/windows/readline.dll +0 -0
  64. package/resources/bin/windows/usbmuxd.dll +0 -0
  65. package/resources/bin/windows/usbmuxd.exe +0 -0
  66. package/resources/bin/windows/vcruntime140.dll +0 -0
  67. package/resources/bin/windows/zip.dll +0 -0
  68. package/resources/bin/windows/zlib1.dll +0 -0
  69. package/resources/lib/include/libimobiledevice/afc.h +0 -413
  70. package/resources/lib/include/libimobiledevice/bt_packet_logger.h +0 -156
  71. package/resources/lib/include/libimobiledevice/companion_proxy.h +0 -212
  72. package/resources/lib/include/libimobiledevice/debugserver.h +0 -272
  73. package/resources/lib/include/libimobiledevice/diagnostics_relay.h +0 -228
  74. package/resources/lib/include/libimobiledevice/file_relay.h +0 -166
  75. package/resources/lib/include/libimobiledevice/heartbeat.h +0 -137
  76. package/resources/lib/include/libimobiledevice/house_arrest.h +0 -180
  77. package/resources/lib/include/libimobiledevice/installation_proxy.h +0 -505
  78. package/resources/lib/include/libimobiledevice/libimobiledevice.h +0 -444
  79. package/resources/lib/include/libimobiledevice/lockdown.h +0 -577
  80. package/resources/lib/include/libimobiledevice/misagent.h +0 -168
  81. package/resources/lib/include/libimobiledevice/mobile_image_mounter.h +0 -275
  82. package/resources/lib/include/libimobiledevice/mobileactivation.h +0 -192
  83. package/resources/lib/include/libimobiledevice/mobilebackup.h +0 -246
  84. package/resources/lib/include/libimobiledevice/mobilebackup2.h +0 -214
  85. package/resources/lib/include/libimobiledevice/mobilesync.h +0 -359
  86. package/resources/lib/include/libimobiledevice/notification_proxy.h +0 -202
  87. package/resources/lib/include/libimobiledevice/ostrace.h +0 -198
  88. package/resources/lib/include/libimobiledevice/preboard.h +0 -187
  89. package/resources/lib/include/libimobiledevice/property_list_service.h +0 -184
  90. package/resources/lib/include/libimobiledevice/restore.h +0 -179
  91. package/resources/lib/include/libimobiledevice/reverse_proxy.h +0 -213
  92. package/resources/lib/include/libimobiledevice/sbservices.h +0 -175
  93. package/resources/lib/include/libimobiledevice/screenshotr.h +0 -118
  94. package/resources/lib/include/libimobiledevice/service.h +0 -202
  95. package/resources/lib/include/libimobiledevice/syslog_relay.h +0 -184
  96. package/resources/lib/include/libimobiledevice/webinspector.h +0 -137
  97. package/resources/lib/include/plist/Array.h +0 -80
  98. package/resources/lib/include/plist/Boolean.h +0 -48
  99. package/resources/lib/include/plist/Data.h +0 -50
  100. package/resources/lib/include/plist/Date.h +0 -54
  101. package/resources/lib/include/plist/Dictionary.h +0 -73
  102. package/resources/lib/include/plist/Integer.h +0 -54
  103. package/resources/lib/include/plist/Key.h +0 -49
  104. package/resources/lib/include/plist/Node.h +0 -57
  105. package/resources/lib/include/plist/Real.h +0 -48
  106. package/resources/lib/include/plist/String.h +0 -52
  107. package/resources/lib/include/plist/Structure.h +0 -62
  108. package/resources/lib/include/plist/Uid.h +0 -48
  109. package/resources/lib/include/plist/plist++.h +0 -39
  110. package/resources/lib/include/plist/plist.h +0 -1448
  111. package/resources/lib/libimobiledevice-1.0.dll +0 -0
  112. package/resources/lib/libimobiledevice-1.0.dll.a +0 -0
  113. package/resources/lib/libplist-2.0.dll +0 -0
  114. package/resources/lib/libplist-2.0.dll.a +0 -0
package/README.md CHANGED
@@ -1,250 +1,284 @@
1
- # @mcesystems/apple-kit
2
-
3
- iOS device management toolkit using libimobiledevice command-line tools. Provides device detection, app installation/uninstallation, port forwarding, activation, and device property access.
4
-
5
- ## Features
6
-
7
- - **Device Detection**: Monitor iOS device connections via USB plug-and-play
8
- - **App Management**: Install and uninstall iOS applications (.ipa files)
9
- - **Launch Apps**: Start applications on the device
10
- - **Port Forwarding**: Forward local ports to device ports (for debugging, etc.)
11
- - **Device Activation**: Check and manage device activation state
12
- - **Trust/Pairing**: Handle device trust and pairing
13
- - **Device Info**: Access device properties (name, model, iOS version, UDID, etc.)
14
- - **Cross-platform**: Works on Windows, macOS, and Linux
15
-
16
- ## Installation
17
-
18
- ```bash
19
- npm install @mcesystems/apple-kit
20
- ```
21
-
22
- ## Requirements
23
-
24
- - Node.js 18+
25
- - iOS device connected via USB
26
- - Device must be trusted/paired with the computer
27
- - libimobiledevice binaries (included for Windows, see BUILD.md for other platforms)
28
- - iTunes installed OR run the bundled `usbmuxd` (see below)
29
-
30
- ## Usage
31
-
32
- ### Device Monitoring
33
-
34
- ```typescript
35
- import { DevicesMonitor } from '@mcesystems/apple-kit';
36
-
37
- const monitor = new DevicesMonitor({
38
- logicalPortMap: {
39
- "Port_#0005.Hub_#0002": 1,
40
- "Port_#0006.Hub_#0002": 2
41
- }
42
- });
43
-
44
- const events = await monitor.startTracking();
45
-
46
- events.on('added', async (deviceKit) => {
47
- console.log(`iOS device connected: ${deviceKit.getDeviceId()}`);
48
- const info = await deviceKit.getDeviceInfo();
49
- console.log(` ${info.deviceName} - iOS ${info.productVersion}`);
50
- });
51
-
52
- events.on('removed', (deviceId, port) => {
53
- console.log(`iOS device disconnected: ${deviceId}`);
54
- });
55
-
56
- // Later: stop monitoring
57
- await monitor.stopTracking();
58
- ```
59
-
60
- ### Install/Uninstall Agent
61
-
62
- ```typescript
63
- import { AppleDeviceKit } from '@mcesystems/apple-kit';
64
-
65
- const device = new AppleDeviceKit('device-udid', 1);
66
-
67
- // Install an agent/app
68
- await device.installApp('/path/to/agent.ipa');
69
-
70
- // Check if installed
71
- const isInstalled = await device.isAppInstalled('com.example.agent');
72
-
73
- // List all installed apps
74
- const apps = await device.listApps();
75
-
76
- // Uninstall an agent/app
77
- await device.uninstallApp('com.example.agent');
78
- ```
79
-
80
- ### Device Info
81
-
82
- ```typescript
83
- const device = new AppleDeviceKit('device-udid', 1);
84
-
85
- const info = await device.getDeviceInfo();
86
- console.log(`Device: ${info.deviceName}`);
87
- console.log(`Model: ${info.productType}`);
88
- console.log(`iOS: ${info.productVersion} (${info.buildVersion})`);
89
- console.log(`Serial: ${info.serialNumber}`);
90
- console.log(`UDID: ${info.udid}`);
91
- ```
92
-
93
- ### Trust/Pairing
94
-
95
- ```typescript
96
- const device = new AppleDeviceKit('device-udid', 1);
97
-
98
- // Check if device is trusted
99
- const isPaired = await device.isPaired();
100
-
101
- // Initiate pairing (user must accept on device)
102
- await device.pair();
103
-
104
- // Wait for user to accept trust dialog
105
- await device.waitForPairing(60000); // 60 second timeout
106
-
107
- // Unpair device
108
- await device.unpair();
109
- ```
110
-
111
- ### Launch Application
112
-
113
- ```typescript
114
- const device = new AppleDeviceKit('device-udid', 1);
115
-
116
- // Launch an app
117
- await device.launchApp('com.example.myapp');
118
-
119
- // Launch with arguments
120
- await device.launchApp('com.example.myapp', ['--debug', '--port=8080']);
121
- ```
122
-
123
- ### Port Forwarding
124
-
125
- ```typescript
126
- const device = new AppleDeviceKit('device-udid', 1);
127
-
128
- // Forward local port 8080 to device port 8080
129
- const forward = device.startPortForward(8080, 8080);
130
-
131
- // Use the forwarded connection...
132
- // connect to localhost:8080 to reach device:8080
133
-
134
- // Stop forwarding when done
135
- forward.stop();
136
-
137
- // Or use async version that waits for ready
138
- const forwardAsync = await device.startPortForwardAsync(8080, 8080);
139
- ```
140
-
141
- ### Activation
142
-
143
- ```typescript
144
- const device = new AppleDeviceKit('device-udid', 1);
145
-
146
- // Get activation state
147
- const state = await device.getActivationState();
148
- console.log(`Activated: ${state.isActivated}`);
149
- console.log(`State: ${state.activationState}`);
150
-
151
- // Activate device (requires valid activation record)
152
- await device.activate();
153
-
154
- // Deactivate device
155
- await device.deactivate();
156
- ```
157
-
158
- ### Running Without iTunes (usbmuxd)
159
-
160
- On Windows, iTunes provides the Apple Mobile Device Service for USB communication. If you don't have iTunes installed, you can run the bundled `usbmuxd`:
161
-
162
- ```typescript
163
- import { startUsbmuxd, stopUsbmuxd, ensureUsbmuxd } from '@mcesystems/apple-kit';
164
-
165
- // Start usbmuxd daemon (required if iTunes is not installed)
166
- const daemon = startUsbmuxd();
167
-
168
- // Or ensure it's running (starts if not already running)
169
- ensureUsbmuxd();
170
-
171
- // Now you can use device operations...
172
- const devices = await AppleDeviceKit.listDevices();
173
-
174
- // When done, stop the daemon
175
- stopUsbmuxd();
176
- // or
177
- daemon.stop();
178
- ```
179
-
180
- **Note:** The usbmuxd daemon must be running before connecting devices. Start it before plugging in your iOS device.
181
-
182
- ## API Reference
183
-
184
- ### AppleDeviceKit
185
-
186
- **Static methods:**
187
- - `listDevices()`: Get all connected iOS devices
188
-
189
- **Device Info:**
190
- - `getDeviceInfo()`: Get device properties
191
- - `getDeviceId()`: Get the device UDID
192
- - `getPort()`: Get the logical port number
193
-
194
- **App Management:**
195
- - `installApp(ipaPath)`: Install an IPA file
196
- - `uninstallApp(bundleId)`: Uninstall an app by bundle ID
197
- - `isAppInstalled(bundleId)`: Check if app is installed
198
- - `listApps()`: List all installed user apps
199
- - `launchApp(bundleId, args?)`: Launch an application
200
-
201
- **Trust/Pairing:**
202
- - `isPaired()`: Check if device is paired/trusted
203
- - `pair()`: Initiate pairing (user must accept on device)
204
- - `unpair()`: Remove pairing/trust
205
- - `waitForPairing(timeout?)`: Wait for device to be paired
206
-
207
- **Port Forwarding:**
208
- - `startPortForward(localPort, devicePort)`: Start port forwarding
209
- - `startPortForwardAsync(localPort, devicePort)`: Start and wait for ready
210
-
211
- **Activation:**
212
- - `getActivationState()`: Get activation state
213
- - `activate()`: Activate the device
214
- - `deactivate()`: Deactivate the device
215
-
216
- ### DevicesMonitor
217
-
218
- - `startTracking()`: Start monitoring for iOS device connections
219
- - `stopTracking()`: Stop monitoring
220
- - `getKits()`: Get all currently tracked devices
221
- - `getKit(udid)`: Get a specific device kit by UDID
222
-
223
- ### usbmuxd Functions
224
-
225
- - `startUsbmuxd(foreground?)`: Start the usbmuxd daemon
226
- - `stopUsbmuxd()`: Stop the daemon
227
- - `isUsbmuxdRunning()`: Check if daemon is running
228
- - `ensureUsbmuxd()`: Start if not already running
229
-
230
- ### Types
231
-
232
- ```typescript
233
- interface PortForwardHandle {
234
- stop: () => void;
235
- localPort: number;
236
- devicePort: number;
237
- process: ChildProcess;
238
- }
239
-
240
- interface ActivationState {
241
- isActivated: boolean;
242
- activationState: string;
243
- }
244
- ```
245
-
246
- ## License
247
-
248
- ISC
249
-
250
- libimobiledevice is licensed under LGPL-2.1.
1
+ # @mcesystems/apple-kit
2
+
3
+ iOS device management toolkit using libimobiledevice command-line tools. Provides device detection, app installation/uninstallation, port forwarding, activation, and device property access.
4
+
5
+ ## Features
6
+
7
+ - **Device Detection**: Monitor iOS device connections via USB plug-and-play
8
+ - **App Management**: Install and uninstall iOS applications (.ipa files)
9
+ - **Launch Apps**: Start applications on the device
10
+ - **Port Forwarding**: Forward local ports to device ports (for debugging, etc.)
11
+ - **Device Activation**: Check and manage device activation state
12
+ - **Trust/Pairing**: Handle device trust and pairing
13
+ - **Device Info**: Access device properties (name, model, iOS version, UDID, etc.)
14
+ - **Cross-platform**: Works on Windows, macOS, and Linux
15
+
16
+ ## Installation
17
+
18
+ ```bash
19
+ npm install @mcesystems/apple-kit
20
+ ```
21
+
22
+ ## Requirements
23
+
24
+ - Node.js 18+
25
+ - iOS device connected via USB
26
+ - Device must be trusted/paired with the computer
27
+
28
+ ### Platform-specific Requirements
29
+
30
+ #### Windows
31
+ - libimobiledevice binaries - use the export script (see below)
32
+ - iTunes installed OR Apple Mobile Device Support
33
+
34
+ #### macOS
35
+ **Option 1: Use bundled binaries (recommended for distribution)**
36
+
37
+ Use the export script to bundle binaries for your application:
38
+ ```bash
39
+ # Using npx (after installing the package)
40
+ npx export-apple-resources /path/to/your-app/resources/apple-kit
41
+
42
+ # Or run the script directly
43
+ npx tsx node_modules/@mcesystems/apple-kit/scripts/export-resources.ts /path/to/your-app/resources
44
+ ```
45
+
46
+ See [scripts/README.md](./scripts/README.md) for detailed prerequisites and instructions.
47
+
48
+ **Option 2: Use Homebrew installation (for development)**
49
+ - Install via Homebrew: `brew install libimobiledevice ideviceinstaller`
50
+ - Tools are auto-detected from `/opt/homebrew/bin` (Apple Silicon) or `/usr/local/bin` (Intel)
51
+
52
+ #### Linux
53
+ - libimobiledevice-utils: `sudo apt install libimobiledevice-utils`
54
+ - Tools are auto-detected from `/usr/bin` or `/usr/local/bin`
55
+
56
+ ### Binary Resolution Order
57
+
58
+ The package looks for idevice tools in this order:
59
+ 1. `IDeviceBinPath` environment variable (for custom paths)
60
+ 2. Bundled resources in your app's `resources/bin/{platform}/` directory
61
+ 3. Homebrew paths on macOS (`/opt/homebrew/bin`, `/usr/local/bin`)
62
+ 4. System PATH (for global installations)
63
+
64
+ ## Usage
65
+
66
+ ### Device Monitoring
67
+
68
+ ```typescript
69
+ import { DevicesMonitor } from '@mcesystems/apple-kit';
70
+
71
+ const monitor = new DevicesMonitor({
72
+ logicalPortMap: {
73
+ "Port_#0005.Hub_#0002": 1,
74
+ "Port_#0006.Hub_#0002": 2
75
+ }
76
+ });
77
+
78
+ const events = await monitor.startTracking();
79
+
80
+ events.on('added', async (deviceKit) => {
81
+ console.log(`iOS device connected: ${deviceKit.getDeviceId()}`);
82
+ const info = await deviceKit.getDeviceInfo();
83
+ console.log(` ${info.deviceName} - iOS ${info.productVersion}`);
84
+ });
85
+
86
+ events.on('removed', (deviceId, port) => {
87
+ console.log(`iOS device disconnected: ${deviceId}`);
88
+ });
89
+
90
+ // Later: stop monitoring
91
+ await monitor.stopTracking();
92
+ ```
93
+
94
+ ### Install/Uninstall Agent
95
+
96
+ ```typescript
97
+ import { AppleDeviceKit } from '@mcesystems/apple-kit';
98
+
99
+ const device = new AppleDeviceKit('device-udid', 1);
100
+
101
+ // Install an agent/app
102
+ await device.installApp('/path/to/agent.ipa');
103
+
104
+ // Check if installed
105
+ const isInstalled = await device.isAppInstalled('com.example.agent');
106
+
107
+ // List all installed apps
108
+ const apps = await device.listApps();
109
+
110
+ // Uninstall an agent/app
111
+ await device.uninstallApp('com.example.agent');
112
+ ```
113
+
114
+ ### Device Info
115
+
116
+ ```typescript
117
+ const device = new AppleDeviceKit('device-udid', 1);
118
+
119
+ const info = await device.getDeviceInfo();
120
+ console.log(`Device: ${info.deviceName}`);
121
+ console.log(`Model: ${info.productType}`);
122
+ console.log(`iOS: ${info.productVersion} (${info.buildVersion})`);
123
+ console.log(`Serial: ${info.serialNumber}`);
124
+ console.log(`UDID: ${info.udid}`);
125
+ ```
126
+
127
+ ### Trust/Pairing
128
+
129
+ ```typescript
130
+ const device = new AppleDeviceKit('device-udid', 1);
131
+
132
+ // Check if device is trusted
133
+ const isPaired = await device.isPaired();
134
+
135
+ // Initiate pairing (user must accept on device)
136
+ await device.pair();
137
+
138
+ // Wait for user to accept trust dialog
139
+ await device.waitForPairing(60000); // 60 second timeout
140
+
141
+ // Unpair device
142
+ await device.unpair();
143
+ ```
144
+
145
+ ### Launch Application
146
+
147
+ ```typescript
148
+ const device = new AppleDeviceKit('device-udid', 1);
149
+
150
+ // Launch an app
151
+ await device.launchApp('com.example.myapp');
152
+
153
+ // Launch with arguments
154
+ await device.launchApp('com.example.myapp', ['--debug', '--port=8080']);
155
+ ```
156
+
157
+ ### Port Forwarding
158
+
159
+ ```typescript
160
+ const device = new AppleDeviceKit('device-udid', 1);
161
+
162
+ // Forward local port 8080 to device port 8080
163
+ const forward = device.startPortForward(8080, 8080);
164
+
165
+ // Use the forwarded connection...
166
+ // connect to localhost:8080 to reach device:8080
167
+
168
+ // Stop forwarding when done
169
+ forward.stop();
170
+
171
+ // Or use async version that waits for ready
172
+ const forwardAsync = await device.startPortForwardAsync(8080, 8080);
173
+ ```
174
+
175
+ ### Activation
176
+
177
+ ```typescript
178
+ const device = new AppleDeviceKit('device-udid', 1);
179
+
180
+ // Get activation state
181
+ const state = await device.getActivationState();
182
+ console.log(`Activated: ${state.isActivated}`);
183
+ console.log(`State: ${state.activationState}`);
184
+
185
+ // Activate device (requires valid activation record)
186
+ await device.activate();
187
+
188
+ // Deactivate device
189
+ await device.deactivate();
190
+ ```
191
+
192
+ ### Running Without iTunes (usbmuxd)
193
+
194
+ On Windows, iTunes provides the Apple Mobile Device Service for USB communication. If you don't have iTunes installed, you can run the bundled `usbmuxd`:
195
+
196
+ ```typescript
197
+ import { startUsbmuxd, stopUsbmuxd, ensureUsbmuxd } from '@mcesystems/apple-kit';
198
+
199
+ // Start usbmuxd daemon (required if iTunes is not installed)
200
+ const daemon = startUsbmuxd();
201
+
202
+ // Or ensure it's running (starts if not already running)
203
+ ensureUsbmuxd();
204
+
205
+ // Now you can use device operations...
206
+ const devices = await AppleDeviceKit.listDevices();
207
+
208
+ // When done, stop the daemon
209
+ stopUsbmuxd();
210
+ // or
211
+ daemon.stop();
212
+ ```
213
+
214
+ **Note:** The usbmuxd daemon must be running before connecting devices. Start it before plugging in your iOS device.
215
+
216
+ ## API Reference
217
+
218
+ ### AppleDeviceKit
219
+
220
+ **Static methods:**
221
+ - `listDevices()`: Get all connected iOS devices
222
+
223
+ **Device Info:**
224
+ - `getDeviceInfo()`: Get device properties
225
+ - `getDeviceId()`: Get the device UDID
226
+ - `getPort()`: Get the logical port number
227
+
228
+ **App Management:**
229
+ - `installApp(ipaPath)`: Install an IPA file
230
+ - `uninstallApp(bundleId)`: Uninstall an app by bundle ID
231
+ - `isAppInstalled(bundleId)`: Check if app is installed
232
+ - `listApps()`: List all installed user apps
233
+ - `launchApp(bundleId, args?)`: Launch an application
234
+
235
+ **Trust/Pairing:**
236
+ - `isPaired()`: Check if device is paired/trusted
237
+ - `pair()`: Initiate pairing (user must accept on device)
238
+ - `unpair()`: Remove pairing/trust
239
+ - `waitForPairing(timeout?)`: Wait for device to be paired
240
+
241
+ **Port Forwarding:**
242
+ - `startPortForward(localPort, devicePort)`: Start port forwarding
243
+ - `startPortForwardAsync(localPort, devicePort)`: Start and wait for ready
244
+
245
+ **Activation:**
246
+ - `getActivationState()`: Get activation state
247
+ - `activate()`: Activate the device
248
+ - `deactivate()`: Deactivate the device
249
+
250
+ ### DevicesMonitor
251
+
252
+ - `startTracking()`: Start monitoring for iOS device connections
253
+ - `stopTracking()`: Stop monitoring
254
+ - `getKits()`: Get all currently tracked devices
255
+ - `getKit(udid)`: Get a specific device kit by UDID
256
+
257
+ ### usbmuxd Functions
258
+
259
+ - `startUsbmuxd(foreground?)`: Start the usbmuxd daemon
260
+ - `stopUsbmuxd()`: Stop the daemon
261
+ - `isUsbmuxdRunning()`: Check if daemon is running
262
+ - `ensureUsbmuxd()`: Start if not already running
263
+
264
+ ### Types
265
+
266
+ ```typescript
267
+ interface PortForwardHandle {
268
+ stop: () => void;
269
+ localPort: number;
270
+ devicePort: number;
271
+ process: ChildProcess;
272
+ }
273
+
274
+ interface ActivationState {
275
+ isActivated: boolean;
276
+ activationState: string;
277
+ }
278
+ ```
279
+
280
+ ## License
281
+
282
+ ISC
283
+
284
+ libimobiledevice is licensed under LGPL-2.1.