Repository navigation
feat(ios): serve Vite dev over the USB CoreDevice tunnel #6210
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
+1,006
−3
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
1113346
feat(ios): serve Vite dev over the USB CoreDevice tunnel
edusperoni 100d250
fix(ios): count only the --device selection when deciding on the USB …
edusperoni fb53797
refactor(ios): build the USB tunnel service on the DI contract
edusperoni e1b9e4e
test(ios): register the USB tunnel service and its stubs by contract …
edusperoni 4483954
refactor(ios): make the USB tunnel service an internal contract
edusperoni 1ddece8
style(ios): match the DI conventions used elsewhere
edusperoni 99b94e0
refactor(ios): implement the USB tunnel service's contract rather tha…
edusperoni File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import { Contract } from "../../common/di/contract"; | ||
|
|
||
| /** | ||
| * Holds the CoreDevice tunnel of a USB-connected iOS 17+ / visionOS device | ||
| * so an app can reach the Vite dev server on the Mac over the cable, without | ||
| * Wi-Fi or the Local Network prompt. | ||
| */ | ||
| @Contract() | ||
| export abstract class IOSDeviceTunnelService { | ||
| /** | ||
| * Opens the device's CoreDevice tunnel and keeps it up until `close` or | ||
| * the CLI exits. Resolves the Mac's address on the tunnel, or null when | ||
| * the device has no usable USB tunnel. A tunnel gets a new address every | ||
| * time it is re-established. | ||
| */ | ||
| abstract open(device: Mobile.IDevice): Promise<string | null>; | ||
|
|
||
| /** | ||
| * The Mac's tunnel address for the single device of `platform` that has | ||
| * an open tunnel, if any. | ||
| */ | ||
| abstract getHostAddress(platform: string): string | undefined; | ||
|
|
||
| abstract close(deviceIdentifier: string): Promise<void>; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A second iOS device in the same run can receive a bundle with the first device's tunnel origin.
The tunnel origin is set when the first iOS device starts the Vite dev server. When a second iOS device joins that run, the target count is 2, so the tunnel guard returns without changing the origin. The existing Vite process is then reused for the new device, and its bundle still points to the first device's tunnel address. The second device cannot reach that address, so its module loads and hot updates can fail. Stop does not reset the origin, because it closes only removed devices.
When a run has more than one target for a platform, every target that receives a bundle must be able to reach the dev server origin. Reconfigure the origin, or regenerate the bundle, before the new target is prepared. Keep the tunnel path for sessions that remain single-target.