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
5 changes: 4 additions & 1 deletion examples/sdk/reactNative/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ export SOURCEMAP_FILE="$project_directory/main.jsbundle.map"
source_map_upload="$project_directory/node_modules/@backtrace/react-native/scripts/ios-sourcemap-upload.sh"
backtrace_js_config="$project_directory/.backtracejsrc"

/bin/sh -c "$source_map_upload $SOURCEMAP_FILE $TARGET_BUILD_DIR/.backtrace-sourcemap-id $backtrace_js_config $project_directory"
/bin/sh -c "$source_map_upload $SOURCEMAP_FILE $CONFIGURATION_BUILD_DIR/.backtrace-sourcemap-id $backtrace_js_config $project_directory"

```

The Backtrace serializer writes the debug id file to `$CONFIGURATION_BUILD_DIR`. Under Product > Archive that folder
differs from `$TARGET_BUILD_DIR`, and an archive built with `$TARGET_BUILD_DIR` uploads no source map.
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "set -e\nproject_directory=\"$(pwd)/..\"\n# enable source map support\nexport SOURCEMAP_FILE=\"$project_directory/main.jsbundle.map\"\n\nWITH_ENVIRONMENT=\"$REACT_NATIVE_PATH/scripts/xcode/with-environment.sh\"\nREACT_NATIVE_XCODE=\"$REACT_NATIVE_PATH/scripts/react-native-xcode.sh\"\n\n/bin/sh -c \"$WITH_ENVIRONMENT $REACT_NATIVE_XCODE\"\n\n# upload source maps to Backtrace\nsource_map_upload=\"$project_directory/node_modules/@backtrace/react-native/scripts/ios-sourcemap-upload.sh\"\nbacktrace_js_config=\"$project_directory/.backtracejsrc\"\n\n/bin/sh -c \"$source_map_upload $SOURCEMAP_FILE $TARGET_BUILD_DIR/.backtrace-sourcemap-id $backtrace_js_config $project_directory\" \n\n";
shellScript = "set -e\nproject_directory=\"$(pwd)/..\"\n# enable source map support\nexport SOURCEMAP_FILE=\"$project_directory/main.jsbundle.map\"\n\nWITH_ENVIRONMENT=\"$REACT_NATIVE_PATH/scripts/xcode/with-environment.sh\"\nREACT_NATIVE_XCODE=\"$REACT_NATIVE_PATH/scripts/react-native-xcode.sh\"\n\n/bin/sh -c \"$WITH_ENVIRONMENT $REACT_NATIVE_XCODE\"\n\n# upload source maps to Backtrace\nsource_map_upload=\"$project_directory/node_modules/@backtrace/react-native/scripts/ios-sourcemap-upload.sh\"\nbacktrace_js_config=\"$project_directory/.backtracejsrc\"\n\n/bin/sh -c \"$source_map_upload $SOURCEMAP_FILE $CONFIGURATION_BUILD_DIR/.backtrace-sourcemap-id $backtrace_js_config $project_directory\" \n\n";
};
00EEFC60759A1932668264C0 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
Expand Down
6 changes: 5 additions & 1 deletion packages/react-native/scripts/ios-sourcemap-upload.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
# Usage: ./ios-sourcemap-upload.sh <source_map_file_path> <debug_id_file_path> <backtrace_configuration_path> <project_directory_path>
# Parameters:
# <source_map_file_path> (Required) Path to the source map file.
# <debug_id_file_path> (Required) Path to the debug id file written by the Backtrace metro serializer.
# <debug_id_file_path> (Required) Path to the debug id file written by the Backtrace metro serializer,
# $CONFIGURATION_BUILD_DIR/.backtrace-sourcemap-id inside an Xcode build phase.
# <backtrace_configuration_path> (Required) Path to the .backtracejsrc configuration file.
# <project_directory_path> (Required) Path to the react-native project directory.
# Environment:
Expand Down Expand Up @@ -78,6 +79,9 @@ if [ ! -f "$source_map_file_path" ]; then
fi

if [ ! -f "$debug_id_file_path" ]; then
if [ -n "$CONFIGURATION_BUILD_DIR" ] && [ -f "$CONFIGURATION_BUILD_DIR/.backtrace-sourcemap-id" ]; then
fail "Debug id file '$debug_id_file_path' does not exist. Under Product > Archive it is at '$CONFIGURATION_BUILD_DIR/.backtrace-sourcemap-id'. Pass \$CONFIGURATION_BUILD_DIR/.backtrace-sourcemap-id to this script."
fi
fail "Debug id file '$debug_id_file_path' does not exist. Check if customSerializer has been set to the Backtrace serializer in metro.config.js."
fi

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,39 @@ describeOnUnix('ios-sourcemap-upload.sh', () => {
expect(uploadCall(fixture)).toBeUndefined();
});

it('names the Archive case when the debug id file is only in CONFIGURATION_BUILD_DIR', () => {
const targetBuildDir = path.join(fixture.root, 'Applications');
fs.mkdirSync(targetBuildDir);

const result = run(fixture, {
args: [
fixture.sourceMap,
path.join(targetBuildDir, '.backtrace-sourcemap-id'),
fixture.config,
fixture.project,
],
env: { ...release, CONFIGURATION_BUILD_DIR: path.dirname(fixture.debugId) },
});

expect(result.status).toBe(0);
expect(result.stderr).toMatch(/^warning: Backtrace: Debug id file .* Product > Archive/m);
expect(result.stderr).toContain('Pass $CONFIGURATION_BUILD_DIR/.backtrace-sourcemap-id');
expect(uploadCall(fixture)).toBeUndefined();
});

it('keeps the serializer hint when CONFIGURATION_BUILD_DIR has no debug id file either', () => {
fs.rmSync(fixture.debugId);

const result = run(fixture, {
env: { ...release, CONFIGURATION_BUILD_DIR: path.dirname(fixture.debugId) },
});

expect(result.status).toBe(0);
expect(result.stderr).toMatch(/^warning: Backtrace: Debug id file .* metro\.config\.js/m);
expect(result.stderr).not.toContain('Archive');
expect(uploadCall(fixture)).toBeUndefined();
});

it('warns instead of failing when the configuration file is missing', () => {
fs.rmSync(fixture.config);

Expand Down
Loading