diff --git a/CHANGELOG.md b/CHANGELOG.md index 5743ebc7fe..5e1df03dfd 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 + +- Skip iOS source maps upload on `Debug` builds ([#6405](https://github.com/getsentry/sentry-react-native/pull/6405)) + ## 8.17.2 ### Fixes diff --git a/packages/core/scripts/sentry-xcode.sh b/packages/core/scripts/sentry-xcode.sh index aa4ead6225..1a44688e99 100755 --- a/packages/core/scripts/sentry-xcode.sh +++ b/packages/core/scripts/sentry-xcode.sh @@ -65,7 +65,18 @@ REACT_NATIVE_XCODE_WITH_SENTRY="\"$SENTRY_CLI_EXECUTABLE\" react-native xcode $A exitCode=0 -if [ "$SENTRY_DISABLE_AUTO_UPLOAD" != true ]; then +if [ "$SENTRY_DISABLE_AUTO_UPLOAD" == true ]; then + echo "SENTRY_DISABLE_AUTO_UPLOAD=true, skipping sourcemaps upload" + /bin/sh -c "$REACT_NATIVE_XCODE" +elif echo "$CONFIGURATION" | grep -iq "debug"; then # case insensitive check for "debug" + # Skip the source maps upload for *Debug* configuration, matching the behavior of the + # native debug files upload (sentry-xcode-debug-files.sh) and the Android Gradle plugin. + # Local Debug builds should not require Sentry credentials. Still run the React Native + # bundling step so the build itself succeeds. + # See: https://github.com/getsentry/sentry-react-native/issues/6399 + echo "Skipping source maps upload for *Debug* configuration" + /bin/sh -c "$REACT_NATIVE_XCODE" +else # 'warning:' triggers a warning in Xcode, 'error:' triggers an error set +x +e # disable printing commands otherwise we might print `error:` by accident and allow continuing on error SENTRY_XCODE_COMMAND_OUTPUT=$(/bin/sh -c "\"$LOCAL_NODE_BINARY\" $REACT_NATIVE_XCODE_WITH_SENTRY" 2>&1) @@ -82,9 +93,6 @@ if [ "$SENTRY_DISABLE_AUTO_UPLOAD" != true ]; then fi fi set -x -e # re-enable -else - echo "SENTRY_DISABLE_AUTO_UPLOAD=true, skipping sourcemaps upload" - /bin/sh -c "$REACT_NATIVE_XCODE" fi [ -z "$SENTRY_COLLECT_MODULES" ] && SENTRY_RN_PACKAGE_PATH=$("$LOCAL_NODE_BINARY" --print "require('path').dirname(require.resolve('@sentry/react-native/package.json'))") diff --git a/packages/core/test/scripts/sentry-xcode-scripts.test.ts b/packages/core/test/scripts/sentry-xcode-scripts.test.ts index 90eedcd6c8..3a65af4cae 100644 --- a/packages/core/test/scripts/sentry-xcode-scripts.test.ts +++ b/packages/core/test/scripts/sentry-xcode-scripts.test.ts @@ -455,6 +455,32 @@ describe('sentry-xcode.sh', () => { expect(result.stdout).toContain('skipping sourcemaps upload'); }); + it('skips upload for Debug configuration without invoking sentry-cli', () => { + const result = runScript({ + CONFIGURATION: 'Debug', + // A failing sentry-cli would surface here if it were invoked; the Debug skip must run + // the React Native bundling step directly instead. See issue #6399. + MOCK_CLI_EXIT_CODE: '1', + MOCK_CLI_OUTPUT: 'An organization ID or slug is required', + }); + + expect(result.exitCode).toBe(0); + expect(result.stdout).toContain('Skipping source maps upload for *Debug* configuration'); + expect(result.stdout).toContain('Mock React Native bundle'); + expect(result.stdout).not.toContain('An organization ID or slug is required'); + expect(result.stdout).not.toContain('error: sentry-cli'); + }); + + it('skips upload for debug configuration (case insensitive)', () => { + const result = runScript({ + CONFIGURATION: 'debug', + }); + + expect(result.exitCode).toBe(0); + expect(result.stdout).toContain('Skipping source maps upload for *Debug* configuration'); + expect(result.stdout).toContain('Mock React Native bundle'); + }); + describe('SENTRY_PROJECT_ROOT override', () => { it('resolves SOURCEMAP_FILE relative to SENTRY_PROJECT_ROOT instead of PROJECT_DIR/..', () => { const customRoot = path.join(tempDir, 'monorepo-package');