Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions e2e-tests/tests/react-native.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
checkFileContents,
checkIfReactNativeBundles,
revertLocalChanges,
startWizardInstance
startWizardInstance,
} from '../utils';
import { afterAll, beforeAll, describe, test, expect } from 'vitest';

Expand All @@ -31,7 +31,8 @@ describe('ReactNative', () => {
// Selecting `yarn` as the package manager
[KEYS.DOWN, KEYS.DOWN, KEYS.ENTER],
'Do you want to enable Session Replay to help debug issues? (See https://docs.sentry.io/platforms/react-native/session-replay/)',
), {
),
{
timeout: 240_000,
});

Expand Down Expand Up @@ -192,7 +193,7 @@ defaults.url=https://sentry.io/`,
}
checkFileContents(
`${projectDir}/ios/reactnative078.xcodeproj/project.pbxproj`,
`../node_modules/@sentry/react-native/scripts/sentry-xcode.sh`,
`@sentry/react-native/scripts/sentry-xcode.sh`,
);
checkFileContents(
`${projectDir}/ios/reactnative078.xcodeproj/project.pbxproj`,
Expand Down
5 changes: 5 additions & 0 deletions src/react-native/xcode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ export function addSentryWithBundledScriptsToBundleShellScript(
.replace(
'react-native/scripts/react-native-xcode.sh',
'@sentry/react-native/scripts/sentry-xcode.sh',
)
// that might be needed for older versions of React Native (< 0.81)
.replace(
'$REACT_NATIVE_PATH/scripts/react-native-xcode.sh',
'$REACT_NATIVE_PATH/../@sentry/react-native/scripts/sentry-xcode.sh',
);
}

Expand Down
22 changes: 22 additions & 0 deletions test/react-native/xcode.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,28 @@ REACT_NATIVE_XCODE="../node_modules/react-native/scripts/react-native-xcode.sh"
WITH_ENVIRONMENT="../node_modules/react-native/scripts/xcode/with-environment.sh"
SENTRY_XCODE="../node_modules/@sentry/react-native/scripts/sentry-xcode.sh"

/bin/sh -c "$WITH_ENVIRONMENT $SENTRY_XCODE"`;

expect(addSentryWithBundledScriptsToBundleShellScript(input)).toBe(
expectedOutput,
);
});

it('adds sentry cli to rn bundle build phase for versions of RN that use REACT_NATIVE_PATH env variable', () => {
const input = `set -e

WITH_ENVIRONMENT="../node_modules/react-native/scripts/xcode/with-environment.sh"
REACT_NATIVE_XCODE="$REACT_NATIVE_PATH/scripts/react-native-xcode.sh"

/bin/sh -c "$WITH_ENVIRONMENT $REACT_NATIVE_XCODE"`;
// actual shell script looks like this:
// /bin/sh -c "$WITH_ENVIRONMENT \"$REACT_NATIVE_XCODE\""
// but during parsing xcode library removes the quotes
const expectedOutput = `set -e

WITH_ENVIRONMENT="../node_modules/react-native/scripts/xcode/with-environment.sh"
SENTRY_XCODE="$REACT_NATIVE_PATH/../@sentry/react-native/scripts/sentry-xcode.sh"

/bin/sh -c "$WITH_ENVIRONMENT $SENTRY_XCODE"`;

expect(addSentryWithBundledScriptsToBundleShellScript(input)).toBe(
Expand Down
Loading