diff --git a/packages/plugin-expo-eas-sourcemaps/lib/bugsnag-expo-xcode.sh b/packages/plugin-expo-eas-sourcemaps/lib/bugsnag-expo-xcode.sh index 33457119..60923bda 100755 --- a/packages/plugin-expo-eas-sourcemaps/lib/bugsnag-expo-xcode.sh +++ b/packages/plugin-expo-eas-sourcemaps/lib/bugsnag-expo-xcode.sh @@ -60,4 +60,11 @@ if [ ! -z "$ENDPOINT" ]; then ARGS+=("$ENDPOINT") fi -../node_modules/.bin/bugsnag-source-maps upload-react-native "${ARGS[@]}" +# Make sure that node binary exists +source `$NODE_BINARY --print "require('path').dirname(require.resolve('react-native/package.json')) + '/scripts/node-binary.sh'"` + +# Retrieve the expo node binary +BUGSNAG_EXPO_NODE_BINARY=$($NODE_BINARY --print "require('path').dirname(require.resolve('@bugsnag/source-maps/package.json'))") + +# Start upload the source maps to bugsnag +$BUGSNAG_EXPO_NODE_BINARY upload-react-native "${ARGS[@]}" \ No newline at end of file diff --git a/packages/plugin-expo-eas-sourcemaps/lib/bugsnag-xcode-build-phase b/packages/plugin-expo-eas-sourcemaps/lib/bugsnag-xcode-build-phase new file mode 100644 index 00000000..8b690e25 --- /dev/null +++ b/packages/plugin-expo-eas-sourcemaps/lib/bugsnag-xcode-build-phase @@ -0,0 +1,8 @@ +if [[ -f "$PODS_ROOT/../.xcode.env" ]]; then + source "$PODS_ROOT/../.xcode.env" +fi +if [[ -f "$PODS_ROOT/../.xcode.env.local" ]]; then + source "$PODS_ROOT/../.xcode.env.local" +fi + +SOURCE_MAP="$TMPDIR/$(md5 -qs "$CONFIGURATION_BUILD_DIR")-main.jsbundle.map" `$NODE_BINARY --print "require('path').dirname(require.resolve('@bugsnag/plugin-expo-eas-sourcemaps/package.json')) + '/lib/bugsnag-expo-xcode.sh'"` \ No newline at end of file diff --git a/packages/plugin-expo-eas-sourcemaps/src/ios.js b/packages/plugin-expo-eas-sourcemaps/src/ios.js index e18e9c86..989a67c5 100644 --- a/packages/plugin-expo-eas-sourcemaps/src/ios.js +++ b/packages/plugin-expo-eas-sourcemaps/src/ios.js @@ -2,6 +2,8 @@ const { withInfoPlist, withXcodeProject } = require('@expo/config-plugins') +const { readFileSync } = require('fs'); +const { dirname, join } = require('path'); const buildPhaseName = 'PBXShellScriptBuildPhase' const buildPhaseComment = 'Bundle React Native code and images' @@ -19,19 +21,7 @@ function withIosPlugin (config, onPremConfig) { config = withXcodeProject(config, config => { const xcodeProject = config.modResults - // 02. Update react native bundle phase with sourcemap filepath - const bundleReactNativePhase = xcodeProject.pbxItemByComment(buildPhaseComment, buildPhaseName) - - const initialScript = bundleReactNativePhase.shellScript - - const additionalExports = '"export EXTRA_PACKAGER_ARGS=\\"--sourcemap-output $TMPDIR/$(md5 -qs \\"$CONFIGURATION_BUILD_DIR\\")-main.jsbundle.map\\"\\n' - - const modifiedScript = additionalExports + initialScript.substr(1) - - bundleReactNativePhase.shellScript = modifiedScript - - // 03. Configure the new build phase - const shellScript = 'SOURCE_MAP="$TMPDIR/$(md5 -qs "$CONFIGURATION_BUILD_DIR")-main.jsbundle.map" ../node_modules/@bugsnag/plugin-expo-eas-sourcemaps/lib/bugsnag-expo-xcode.sh' + const shellScript = readFileSync(join(__dirname, '../lib/bugsnag-xcode-build-phase'), 'utf8') xcodeProject.addBuildPhase([], buildPhaseName, 'Upload source maps to Bugsnag', null, { shellPath: '/bin/sh',