diff --git a/CHANGELOG.md b/CHANGELOG.md index a7498c3507..f5dbb6ecae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,12 @@ > make sure you follow our [migration guide](https://docs.sentry.io/platforms/react-native/migration/) first. +## Unreleased + +### Fixes + +- Find `ios/.xcode.env` in the Expo plugin "Upload Debug Symbols to Sentry" phase when the iOS project uses Swift Package Manager instead of CocoaPods ([#6911](https://github.com/getsentry/sentry-react-native/pull/6911)) + ## 8.31.0 ### Features diff --git a/packages/core/plugin/src/withSentryIOS.ts b/packages/core/plugin/src/withSentryIOS.ts index 76b60f4466..62a9e1a1c0 100644 --- a/packages/core/plugin/src/withSentryIOS.ts +++ b/packages/core/plugin/src/withSentryIOS.ts @@ -16,7 +16,9 @@ const SENTRY_REACT_NATIVE_XCODE_DEBUG_FILES_PATH = "`\"${NODE_BINARY:-node}\" --print \"require('path').dirname(require.resolve('@sentry/react-native/package.json')) + '/scripts/sentry-xcode-debug-files.sh'\"`"; const SENTRY_DISABLE_AUTO_UPLOAD_EXPORT = 'export SENTRY_DISABLE_AUTO_UPLOAD=true'; // Xcode started from the Dock has no node on PATH, so load NODE_BINARY the same way as with-environment.sh. -const LOAD_XCODE_ENV = `XCODE_ENV_PATH="\${PODFILE_DIR:-$PODS_ROOT/..}/.xcode.env" +// Swift Package Manager projects have no PODS_ROOT, so use SRCROOT as React Native's SPM build phases do. +const LOAD_XCODE_ENV = `XCODE_ENV_DIR="\${PODFILE_DIR:-\${PODS_ROOT:+$PODS_ROOT/..}}" +XCODE_ENV_PATH="\${XCODE_ENV_DIR:-$SRCROOT}/.xcode.env" [ -f "$XCODE_ENV_PATH" ] && . "$XCODE_ENV_PATH" [ -f "$XCODE_ENV_PATH.local" ] && . "$XCODE_ENV_PATH.local" `; diff --git a/packages/core/test/expo-plugin/modifyXcodeProject.test.ts b/packages/core/test/expo-plugin/modifyXcodeProject.test.ts index d5ac327773..0edc5da100 100644 --- a/packages/core/test/expo-plugin/modifyXcodeProject.test.ts +++ b/packages/core/test/expo-plugin/modifyXcodeProject.test.ts @@ -629,6 +629,25 @@ describe('Upload Debug Symbols phase loads .xcode.env before it resolves the scr expect(stdout).toContain('debug files script ran'); }); + it('uses SRCROOT to find .xcode.env when the project has no CocoaPods', () => { + fs.writeFileSync(path.join(iosDir, '.xcode.env.local'), `export NODE_BINARY="${process.execPath}"\n`); + + const stdout = runPhase(getDebugFilesUploadScript(), { SRCROOT: iosDir }); + + expect(stdout).toContain('debug files script ran'); + }); + + it('uses PODS_ROOT before SRCROOT to find .xcode.env', () => { + fs.writeFileSync(path.join(iosDir, '.xcode.env.local'), `export NODE_BINARY="${process.execPath}"\n`); + + const stdout = runPhase(getDebugFilesUploadScript(), { + PODS_ROOT: path.join(iosDir, 'Pods'), + SRCROOT: '/nonexistent', + }); + + expect(stdout).toContain('debug files script ran'); + }); + it('uses a NODE_BINARY path that contains spaces', () => { const nodeDir = path.join(projectDir, 'dir with spaces'); fs.mkdirSync(nodeDir);