Skip to content

fix(core): Load .xcode.env in the Expo debug files upload phase - #6860

Open
ceydaakin wants to merge 2 commits into
getsentry:mainfrom
ceydaakin:fix/expo-debug-files-phase-load-xcode-env
Open

ceydaakin wants to merge 2 commits into
getsentry:mainfrom
ceydaakin:fix/expo-debug-files-phase-load-xcode-env

Conversation

@ceydaakin

Copy link
Copy Markdown

📢 Type of change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring

📜 Description

The Expo plugin's "Upload Debug Symbols to Sentry" build phase now sources .xcode.env and .xcode.env.local before it resolves the path of sentry-xcode-debug-files.sh, the same way the Expo template's "Bundle React Native code and images" phase does.

Existing projects pick this up on the next expo prebuild, because the plugin already rewrites this Sentry-owned phase.

💡 Motivation and Context

Fixes #6859.

The phase uses ${NODE_BINARY:-node} to locate sentry-xcode-debug-files.sh, but NODE_BINARY is only set by the env files that the script itself loads. When Xcode is launched from the Dock or Finder, node (nvm, Homebrew) is not on the PATH, so the lookup fails before the script runs and the phase exits 127 (/bin/sh: node: command not found).

💚 How did you test it?

  • Two new tests run the generated phase script with /bin/sh and launchd's PATH (/usr/bin:/bin:/usr/sbin:/sbin): one with NODE_BINARY in .xcode.env, one with the default .xcode.env plus .xcode.env.local. Both fail on main and pass with this change.
  • Two existing assertions that pinned export SENTRY_DISABLE_AUTO_UPLOAD=true directly followed by /bin/sh were relaxed, since the env loading now sits between them.
  • yarn jest test/expo-plugin in packages/core: 89 tests pass. oxlint and oxfmt --check are clean on the touched files.
  • Not tested with a full Xcode build.

📝 Checklist

  • I added tests to verify changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • All tests passing.
  • Public API changes reviewed by another Mobile SDK team member or implemented according to the develop docs spec.
  • No breaking changes.

🔮 Next steps

${NODE_BINARY:-node} in this phase is unquoted, so a Node path containing spaces still fails. That is unchanged here.

The "Upload Debug Symbols to Sentry" phase needs Node to locate sentry-xcode-debug-files.sh, but NODE_BINARY is only set by the env files that script loads. When Xcode is launched from the Dock or Finder, `node` is not on the PATH, so the lookup fails before the script runs.

Source .xcode.env and .xcode.env.local in the phase first, as the Expo template's bundle phase does.

Fixes getsentry#6859
fi
if [[ -f "$PODS_ROOT/../.xcode.env.local" ]]; then
source "$PODS_ROOT/../.xcode.env.local"
fi`;

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.

[[ ]] and source are bash features. The Xcode phase works because /bin/sh on macOS is bash. But our Jest jobs run on ubuntu-latest, where /bin/sh is dash. Could you please update it to POSIX form that works on both shells?

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.

maybe something like that:

const LOAD_XCODE_ENV = `if [ -f "$PODS_ROOT/../.xcode.env" ]; then
  . "$PODS_ROOT/../.xcode.env"
fi
if [ -f "$PODS_ROOT/../.xcode.env.local" ]; then
  . "$PODS_ROOT/../.xcode.env.local"
fi`;

@alwx

alwx commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Hey @ceydaakin and thanks for your PR!
I've reviewed it and identified a small issue, can you please take a look at it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants