Skip to content

fix: embedded debug bundle in Expo dev mode - #391

Merged
artus9033 merged 5 commits into
mainfrom
adamTrz/fix-expo-debug-embedded-bundle
Jun 22, 2026
Merged

fix: embedded debug bundle in Expo dev mode#391
artus9033 merged 5 commits into
mainfrom
adamTrz/fix-expo-debug-embedded-bundle

Conversation

@adamTrz

@adamTrz adamTrz commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Force iOS framework Debug embedded bundles to pass --dev false to the React Native bundling script.
  • Add a regression assertion for the Expo config-plugin script rewrite.

Root cause

Expo debug bundles generated for embedded framework use were still emitted with JS dev mode enabled. When the host app loaded that embedded bundle without the Expo/Metro dev server, Expo devtools code attempted to create dev-server websocket endpoints and threw Cannot create devtools websocket connections in embedded environments.

Impact

Debug framework packaging can still embed JS, but the embedded bundle now behaves like a server-independent bundle instead of depending on Expo dev-server-only runtime paths.

Validation

  • Red regression test failed before the implementation change on the missing EXTRA_PACKAGER_ARGS override.
  • yarn workspace @callstack/react-native-brownfield test
  • Commit hook: brownfield-navigation-drift, turbo typecheck, turbo lint

@artus9033
artus9033 marked this pull request as ready for review June 22, 2026 11:31
Copilot AI review requested due to automatic review settings June 22, 2026 11:31
@artus9033 artus9033 changed the title [codex] Fix Expo embedded debug bundle dev mode fix: Expo embedded debug bundle dev mode Jun 22, 2026
@artus9033
artus9033 requested a review from hurali97 June 22, 2026 11:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes Expo iOS framework Debug embedded bundle behavior so embedded bundles are generated with dev-mode transforms disabled, and refines Debug bundle URL resolution to prefer Metro when available while allowing an embedded-bundle fallback when Metro is unavailable.

Changes:

  • Force embedded framework Debug bundling to pass --dev false via EXTRA_PACKAGER_ARGS (CI/local scripts + Expo config-plugin rewrite).
  • Update iOS runtime bundle URL resolution behavior/docs to “Metro first in Debug, embedded fallback when enabled”.
  • Add/adjust regression tests for the config-plugin rewrite and SwiftPM bundle URL resolver behavior; add Node test coverage for Detox simulator device selection.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
scripts/ci-local-ios-e2e-common.sh Ensures Detox/CI embedded bundle builds disable dev transforms via EXTRA_PACKAGER_ARGS.
packages/react-native-brownfield/src/expo-config-plugin/ios/xcodeHelpers.ts Injects --dev false into the rewritten Xcode bundling phase for framework targets.
packages/react-native-brownfield/src/expo-config-plugin/ios/tests/xcodeHelpers.test.ts Adds assertions ensuring the rewrite includes the new EXTRA_PACKAGER_ARGS export.
packages/react-native-brownfield/ios/Vanilla/ReactNativeHostRuntime.swift Uses fallbackURLProvider: { nil } for Metro URL detection; clarifies Debug embedded fallback semantics.
packages/react-native-brownfield/ios/Expo/ExpoHostRuntime.swift Same Metro URL fallback behavior for Expo runtime delegate; updates Debug fallback docs.
packages/react-native-brownfield/ios/ReactNativeBrownfield.swift Updates API docs to match “Debug fallback when Metro unavailable”.
packages/react-native-brownfield/ios/swiftpm/Sources/BrownfieldBundleSupport/BrownfieldBundleURLResolver.swift Changes Debug resolution to prefer Metro when available, with optional embedded fallback.
packages/react-native-brownfield/ios/swiftpm/Tests/BrownfieldBundleSupportTests/BrownfieldBundleURLResolverTests.swift Splits/updates tests to cover Metro-first + embedded-fallback behavior.
apps/brownfield-example-shared-tests/package.json Enables Node test runner for .test.cjs files.
apps/brownfield-example-shared-tests/e2e/expoPostMessageBrownfield.e2e.js Refactors E2E navigation into a helper (but currently leaves Detox sync disabled).
apps/brownfield-example-shared-tests/detox-ios-simulator-device.cjs Refactors simulator selection to prefer installed simulators over uncreated device types.
apps/brownfield-example-shared-tests/detox-ios-simulator-device.test.cjs Adds Node tests for simulator device selection behavior.
.changeset/expo-debug-embedded-bundle.md Changeset documenting the patch release.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 450 to 454
export function rewriteBundleReactNativePhaseScriptForFrameworkTarget(
shellScript: string
): string {
const debugBundlingOverride = `# Brownfield framework packaging must embed JS in Debug builds.
if [[ "$CONFIGURATION" = *Debug* ]]; then

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@artus9033 artus9033 changed the title fix: Expo embedded debug bundle dev mode fix: embedded debug bundle in Expo dev mode Jun 22, 2026

@hurali97 hurali97 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, Please verify Copilot's comments!

artus9033 and others added 2 commits June 22, 2026 13:41
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@artus9033
artus9033 merged commit 95dbb43 into main Jun 22, 2026
16 checks passed
@artus9033
artus9033 deleted the adamTrz/fix-expo-debug-embedded-bundle branch June 22, 2026 12:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants