Make the iOS hot-reload port configurable - #357
Open
shanerbaner82 wants to merge 2 commits into
Open
Conversation
The in-app hot-reload server bound a hardcoded 9999. That port is host-wide — a simulator shares the host's localhost, and physical devices are tunnelled to the same host port by iproxy — so only one app could hot-reload at a time. A second app (or a stale instance of the same one) silently answered the reload trigger instead, leaving the live app synced but never reloaded. Adds `nativephp.hot_reload.port`, defaulting to 9999 so nothing changes for existing apps. Swift can't read the Laravel config, so the value is written into Info.plist at build time and read back from the bundle at launch, with the same 9999 fallback for apps built before the key existed. iOS only: Android signals a reload by pushing a file into the app's storage over adb and never binds a port. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
config() does not treat an empty published key as missing, so these cases would otherwise bake port 0 into Info.plist.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Why
The in-app hot-reload server bound a hardcoded
9999. That port is host-wide — a simulator shares the host's localhost, and physical devices are tunnelled to the same host port by iproxy — so only one app could hot-reload at a time.Worse, the collision is silent. When a second app (or a stale instance of the same one) already holds the port,
triggerIosReload()'sfsockopenconnects successfully and reports nothing wrong. The trigger lands on the wrong listener, so files sync, watchman reports success, and the live app never reloads.What
Adds
nativephp.hot_reload.port, defaulting to9999— no behaviour change for existing apps.HasHotReloadPort— onehotReloadPort()accessor, used byWatchesIos,RunsIos, andBuildIosAppCommandWatchesIos— reload trigger, iproxy forward ({port}:{port}), bothlsofcleanups, and the failure messageRunsIos— the pre-launch port freeBuildIosAppCommand— writesNATIVEPHP_HOT_RELOAD_PORTinto Info.plist, alongside the existingBIFROST_APP_IDhandlingHotReloadServer.swift— reads that key fromBundle.main, falling back to 9999Swift can't read the Laravel config, so the port has to be baked into Info.plist at build time and read back at launch. Changing the port therefore needs a rebuild — noted in the config comment.
iOS only. Android signals a reload by pushing a file into the app's storage over adb and never binds a port, so it ignores the key.
Tests
tests/Feature/IosHotReloadPortTest.php, modelled onIosInterfaceStyleTest: the configured port is written, an unset port falls back to the default, and an existing key is updated rather than duplicated.The fallback test caught a real bug during development —
config()only applies its default when the key is absent, so an app that published the key but left it empty yielded port0.hotReloadPort()now coerces empty to the default.🤖 Generated with Claude Code