@mcesystems/usbmuxd-instance-manager 1.0.72 → 1.0.74

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.
package/README.md CHANGED
@@ -109,6 +109,22 @@ await service.stop();
109
109
  | `verboseLogging` | boolean | true | Enable verbose output |
110
110
  | `appleVendorId` | string | '05AC' | Apple vendor ID (hex) |
111
111
 
112
+ ### Lockdown sync
113
+
114
+ The manager automatically syncs lockdown (pairing) files between the native Apple/iTunes lockdown directory and Alpine so devices that were already paired on Windows can be used without pairing again in WSL.
115
+
116
+ The lockdown directory is resolved per platform:
117
+ - **Windows**: `C:\ProgramData\Apple\Lockdown` (same directory used by iTunes / Apple Mobile Device)
118
+ - **macOS**: `/var/db/lockdown`
119
+ - **Linux**: `/var/lib/lockdown`
120
+
121
+ Sync behavior:
122
+
123
+ - **To Alpine**: When a device is assigned, that device's plist (`{UDID}.plist`) and `SystemConfiguration.plist` are copied from the Apple lockdown directory to Alpine `/var/lib/lockdown`.
124
+ - **From Alpine**: When the service stops, plists for all devices that were assigned this session (plus `SystemConfiguration.plist` if present) are copied from Alpine back to the Apple lockdown directory so they are available for the next run.
125
+
126
+ **Alpine permissions**: `/var/lib/lockdown` is often root-owned. The sync tries a normal copy first; if that fails (e.g. permission denied), it retries with `sudo cp`. Ensure the WSL user has passwordless sudo for these commands, or that the Alpine image has `/var/lib/lockdown` writable by the default user. If both fail, a warning is logged and device assignment continues (pairing can still be done manually).
127
+
112
128
  ## CLI Options
113
129
 
114
130
  ```
@@ -118,7 +134,8 @@ Options:
118
134
  --batchSize <n> Number of devices per instance (default: 4)
119
135
  --basePort <port> Base TCP port for first instance (default: 27015)
120
136
  --maxInstances <n> Maximum number of instances (default: 20)
121
- --usbmuxdPath <path> Path to usbmuxd executable
137
+ --usbmuxdPath <path> Path to usbmuxd executable (WSL: default usbmuxd)
138
+ --wslDistribution <n> WSL distribution name (default: alpine-usbmuxd-build)
122
139
  --verbose <true|false> Enable verbose logging (default: true)
123
140
  --appleVid <vid> Apple Vendor ID in hex (default: 05AC)
124
141
  -h, --help Show this help message
@@ -162,6 +179,65 @@ When all devices disconnect from Instance 2:
162
179
  - Instance 2 automatically terminates
163
180
  - Frees resources
164
181
 
182
+ ## Flow: Working with usbipd and WSL
183
+
184
+ On Windows, the same physical USB device can be used by **either** Windows (e.g. iTunes, Apple Mobile Device) **or** WSL (usbmuxd), not both. usbipd-win is what moves the device between the two.
185
+
186
+ ### Device ownership
187
+
188
+ | State | Who has the device | iTunes / Windows | usbmuxd (WSL) |
189
+ |-------|--------------------|------------------|---------------|
190
+ | Not shared | Windows | ✓ | ✗ |
191
+ | Bound + attached to WSL | WSL | ✗ | ✓ |
192
+ | Bound but detached | Neither (held by usbipd) | ✗ | ✗ |
193
+
194
+ ### Giving the device to usbmuxd (instance manager)
195
+
196
+ 1. **WSL** must be running (e.g. the manager starts it, or run `wsl -d alpine-usbmuxd-build -- echo ok`).
197
+ 2. **Bind** the device (take it from Windows):
198
+ `usbipd bind --busid <BUSID> --force`
199
+ 3. **Attach** to WSL:
200
+ `usbipd attach --wsl=<distro> --busid=<BUSID>`
201
+
202
+ The instance manager does steps 2–3 automatically when it sees an iOS device. You can also use the script:
203
+
204
+ ```powershell
205
+ # From packages/usbmuxd-instance-manager
206
+ .\scripts\attach-device.ps1
207
+ ```
208
+
209
+ ### Giving the device back to Windows (e.g. for iTunes)
210
+
211
+ 1. **Detach** from WSL (stops forwarding to Linux):
212
+ `usbipd detach --busid <BUSID>`
213
+ Or detach all:
214
+ `usbipd detach -a`
215
+ 2. **Unbind** so Windows gets the device back:
216
+ `usbipd unbind --busid <BUSID>`
217
+
218
+ Until you unbind, the device stays "Shared (forced)" and Windows/iTunes will not see it.
219
+
220
+ ### Useful usbipd commands
221
+
222
+ ```powershell
223
+ $usbipd = "C:\Program Files\usbipd-win\usbipd.exe"
224
+
225
+ # List devices and their state (Shared / Not shared, Attached / Not attached)
226
+ & $usbipd list
227
+
228
+ # Detach from WSL (device still bound to usbipd)
229
+ & $usbipd detach --busid 2-5
230
+ & $usbipd detach -a
231
+
232
+ # Unbind so Windows can use the device again (e.g. iTunes)
233
+ & $usbipd unbind --busid 2-5
234
+ ```
235
+
236
+ ### Quick reference
237
+
238
+ - **Use device with usbmuxd-instance-manager** → bind + attach (manager or script does this when you connect a device).
239
+ - **Use device with iTunes on Windows** → detach then unbind for that bus ID; then iTunes will see it.
240
+
165
241
  ## Requirements
166
242
 
167
243
  ### Runtime