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
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
ActionType = "Xcode.IDEStandardExecutionActionsCore.ExecutionActionType.ShellScriptAction">
<ActionContent
title = "Upload dSYMs"
scriptText = "CREDS=&quot;${PROJECT_DIR}/../credentials.json&quot;&#10;TOKEN=&quot;$BUGSEE_APP_TOKEN&quot;&#10;if [ -z &quot;$TOKEN&quot; ]; then&#10; TOKEN=&quot;$BUGSEE_TOKEN_IOS&quot;&#10;fi&#10;if [ -z &quot;$TOKEN&quot; ] &amp;&amp; [ -f &quot;$CREDS&quot; ]; then&#10; TOKEN=$(/usr/bin/plutil -extract ios raw -o - &quot;$CREDS&quot; 2&gt;/dev/null || true)&#10;fi&#10;TOKEN_CHECK=$(printf '%s' &quot;$TOKEN&quot; | /usr/bin/tr -d ' \t\r\n-')&#10;if [ -z &quot;$TOKEN_CHECK&quot; ]; then&#10; echo &quot;warning: bugsee: dSYM upload skipped: no app token is configured&quot;&#10; exit 0&#10;fi&#10;case &quot;$TOKEN_CHECK&quot; in&#10; 000000000000[0123456789abcdefABCDEF]000[0123456789abcdefABCDEF]000000000000000)&#10; echo &quot;warning: bugsee: dSYM upload skipped: the app token is the placeholder&quot;&#10; exit 0&#10; ;;&#10;esac&#10;# An &quot;error:&quot; line reads as a build error to Xcode; a failed upload is a warning.&#10;run_cli() {&#10; CLI_OUT=$(&quot;$@&quot; 2&gt;&amp;1)&#10; CLI_RC=$?&#10; if [ -n &quot;$CLI_OUT&quot; ]; then&#10; printf '%s\n' &quot;$CLI_OUT&quot; | /usr/bin/sed -E 's/^(.*: )?([Ff]atal [Ee]rror|[Ee]rror): (.*)$/warning: bugsee: \3/'&#10; fi&#10; return $CLI_RC&#10;}&#10;if [ -n &quot;$TOKEN&quot; ]; then&#10; export BUGSEE_APP_TOKEN=&quot;$TOKEN&quot;&#10;fi&#10;if [ -z &quot;$BUGSEE_ENDPOINT&quot; ] &amp;&amp; [ -f &quot;$CREDS&quot; ]; then&#10; ENDPOINT=$(/usr/bin/plutil -extract endpoint raw -o - &quot;$CREDS&quot; 2&gt;/dev/null || true)&#10; if [ -n &quot;$ENDPOINT&quot; ]; then&#10; export BUGSEE_ENDPOINT=&quot;$ENDPOINT&quot;&#10; fi&#10;fi&#10;&#10;try_bin() {&#10; if [ -x &quot;$1&quot; ]; then&#10; run_cli &quot;$1&quot; xcode post-action&#10; exit $?&#10; fi&#10;}&#10;&#10;for dir in \&#10; &quot;${PROJECT_DIR}/../node_modules&quot; \&#10; &quot;${PROJECT_DIR}/../node_modules/@bugsee/react-native/node_modules&quot; \&#10; &quot;${PROJECT_DIR}/../../../packages/react-native/node_modules&quot;&#10;do&#10; if [ &quot;$(uname -m)&quot; = &quot;x86_64&quot; ]; then&#10; try_bin &quot;${dir}/@bugsee/cli-darwin-x64/bin/bugsee-cli&quot;&#10; try_bin &quot;${dir}/@bugsee/cli/node_modules/@bugsee/cli-darwin-x64/bin/bugsee-cli&quot;&#10; try_bin &quot;${dir}/@bugsee/cli-darwin-arm64/bin/bugsee-cli&quot;&#10; try_bin &quot;${dir}/@bugsee/cli/node_modules/@bugsee/cli-darwin-arm64/bin/bugsee-cli&quot;&#10; else&#10; try_bin &quot;${dir}/@bugsee/cli-darwin-arm64/bin/bugsee-cli&quot;&#10; try_bin &quot;${dir}/@bugsee/cli/node_modules/@bugsee/cli-darwin-arm64/bin/bugsee-cli&quot;&#10; try_bin &quot;${dir}/@bugsee/cli-darwin-x64/bin/bugsee-cli&quot;&#10; try_bin &quot;${dir}/@bugsee/cli/node_modules/@bugsee/cli-darwin-x64/bin/bugsee-cli&quot;&#10; fi&#10;done&#10;&#10;# Archive's PATH has no node, and the npm shim's shebang searches PATH.&#10;if [ ! -x &quot;$NODE_BINARY&quot; ]; then&#10; if [ -f &quot;${PROJECT_DIR}/.xcode.env&quot; ]; then&#10; . &quot;${PROJECT_DIR}/.xcode.env&quot;&#10; fi&#10; if [ -f &quot;${PROJECT_DIR}/.xcode.env.local&quot; ]; then&#10; . &quot;${PROJECT_DIR}/.xcode.env.local&quot;&#10; fi&#10;fi&#10;if [ ! -x &quot;$NODE_BINARY&quot; ]; then&#10; RN_FIND=&quot;&quot;&#10; if [ -n &quot;$REACT_NATIVE_PATH&quot; ] &amp;&amp; [ -f &quot;$REACT_NATIVE_PATH/scripts/find-node-for-xcode.sh&quot; ]; then&#10; RN_FIND=&quot;$REACT_NATIVE_PATH/scripts/find-node-for-xcode.sh&quot;&#10; elif [ -f &quot;${PROJECT_DIR}/../node_modules/react-native/scripts/find-node-for-xcode.sh&quot; ]; then&#10; RN_FIND=&quot;${PROJECT_DIR}/../node_modules/react-native/scripts/find-node-for-xcode.sh&quot;&#10; fi&#10; if [ -n &quot;$RN_FIND&quot; ]; then&#10; NODE_BINARY=$(/bin/bash -c '. &quot;$1&quot; &gt;/dev/null 2&gt;&amp;1; command -v node' _ &quot;$RN_FIND&quot; || true)&#10; fi&#10;fi&#10;if [ -n &quot;$NODE_BINARY&quot; ] &amp;&amp; [ -x &quot;$NODE_BINARY&quot; ]; then&#10; PATH=&quot;$(dirname &quot;$NODE_BINARY&quot;):$PATH&quot;&#10; export PATH NODE_BINARY&#10; for dir in \&#10; &quot;${PROJECT_DIR}/../node_modules&quot; \&#10; &quot;${PROJECT_DIR}/../node_modules/@bugsee/react-native/node_modules&quot; \&#10; &quot;${PROJECT_DIR}/../../../packages/react-native/node_modules&quot;&#10; do&#10; if [ -f &quot;${dir}/@bugsee/cli/bin/bugsee-cli.js&quot; ]; then&#10; run_cli &quot;$NODE_BINARY&quot; &quot;${dir}/@bugsee/cli/bin/bugsee-cli.js&quot; xcode post-action&#10; exit $?&#10; fi&#10; done&#10;fi&#10;&#10;echo &quot;bugsee-cli: not found under node_modules&quot; &gt;&amp;2&#10;exit 1&#10;">
scriptText = "CREDS=&quot;${PROJECT_DIR}/../credentials.json&quot;&#10;TOKEN=&quot;$BUGSEE_APP_TOKEN&quot;&#10;if [ -z &quot;$TOKEN&quot; ]; then&#10; TOKEN=&quot;$BUGSEE_TOKEN_IOS&quot;&#10;fi&#10;if [ -z &quot;$TOKEN&quot; ]; then&#10; for ENV_FILE in &quot;${PROJECT_DIR}/.xcode.env&quot; &quot;${PROJECT_DIR}/.xcode.env.local&quot;; do&#10; if [ -f &quot;$ENV_FILE&quot; ]; then&#10; ENV_TOKEN=$( ( . &quot;$ENV_FILE&quot; &gt;/dev/null 2&gt;&amp;1; if [ -n &quot;$BUGSEE_APP_TOKEN&quot; ]; then printf '%s' &quot;$BUGSEE_APP_TOKEN&quot;; else printf '%s' &quot;$BUGSEE_TOKEN_IOS&quot;; fi ) 2&gt;/dev/null || true )&#10; if [ -n &quot;$ENV_TOKEN&quot; ]; then&#10; TOKEN=&quot;$ENV_TOKEN&quot;&#10; fi&#10; fi&#10; done&#10;fi&#10;if [ -z &quot;$TOKEN&quot; ] &amp;&amp; [ -f &quot;$CREDS&quot; ]; then&#10; TOKEN=$(/usr/bin/plutil -extract ios raw -o - &quot;$CREDS&quot; 2&gt;/dev/null || true)&#10;fi&#10;TOKEN_CHECK=$(printf '%s' &quot;$TOKEN&quot; | /usr/bin/tr -d ' \t\r\n-')&#10;if [ -z &quot;$TOKEN_CHECK&quot; ]; then&#10; echo &quot;warning: bugsee: dSYM upload skipped: no app token is configured&quot;&#10; exit 0&#10;fi&#10;case &quot;$TOKEN_CHECK&quot; in&#10; 000000000000[0123456789abcdefABCDEF]000[0123456789abcdefABCDEF]000000000000000)&#10; echo &quot;warning: bugsee: dSYM upload skipped: the app token is the placeholder&quot;&#10; exit 0&#10; ;;&#10;esac&#10;# An &quot;error:&quot; line reads as a build error to Xcode; a failed upload is a warning.&#10;run_cli() {&#10; CLI_OUT=$(&quot;$@&quot; 2&gt;&amp;1)&#10; CLI_RC=$?&#10; if [ -n &quot;$CLI_OUT&quot; ]; then&#10; printf '%s\n' &quot;$CLI_OUT&quot; | /usr/bin/sed -E 's/^(.*: )?([Ff]atal [Ee]rror|[Ee]rror): (.*)$/warning: bugsee: \3/'&#10; fi&#10; return $CLI_RC&#10;}&#10;if [ -n &quot;$TOKEN&quot; ]; then&#10; export BUGSEE_APP_TOKEN=&quot;$TOKEN&quot;&#10;fi&#10;if [ -z &quot;$BUGSEE_ENDPOINT&quot; ] &amp;&amp; [ -f &quot;$CREDS&quot; ]; then&#10; ENDPOINT=$(/usr/bin/plutil -extract endpoint raw -o - &quot;$CREDS&quot; 2&gt;/dev/null || true)&#10; if [ -n &quot;$ENDPOINT&quot; ]; then&#10; export BUGSEE_ENDPOINT=&quot;$ENDPOINT&quot;&#10; fi&#10;fi&#10;&#10;try_bin() {&#10; if [ -x &quot;$1&quot; ]; then&#10; run_cli &quot;$1&quot; xcode post-action&#10; exit $?&#10; fi&#10;}&#10;&#10;for dir in \&#10; &quot;${PROJECT_DIR}/../node_modules&quot; \&#10; &quot;${PROJECT_DIR}/../node_modules/@bugsee/react-native/node_modules&quot; \&#10; &quot;${PROJECT_DIR}/../../../packages/react-native/node_modules&quot;&#10;do&#10; if [ &quot;$(uname -m)&quot; = &quot;x86_64&quot; ]; then&#10; try_bin &quot;${dir}/@bugsee/cli-darwin-x64/bin/bugsee-cli&quot;&#10; try_bin &quot;${dir}/@bugsee/cli/node_modules/@bugsee/cli-darwin-x64/bin/bugsee-cli&quot;&#10; try_bin &quot;${dir}/@bugsee/cli-darwin-arm64/bin/bugsee-cli&quot;&#10; try_bin &quot;${dir}/@bugsee/cli/node_modules/@bugsee/cli-darwin-arm64/bin/bugsee-cli&quot;&#10; else&#10; try_bin &quot;${dir}/@bugsee/cli-darwin-arm64/bin/bugsee-cli&quot;&#10; try_bin &quot;${dir}/@bugsee/cli/node_modules/@bugsee/cli-darwin-arm64/bin/bugsee-cli&quot;&#10; try_bin &quot;${dir}/@bugsee/cli-darwin-x64/bin/bugsee-cli&quot;&#10; try_bin &quot;${dir}/@bugsee/cli/node_modules/@bugsee/cli-darwin-x64/bin/bugsee-cli&quot;&#10; fi&#10;done&#10;&#10;# Archive's PATH has no node, and the npm shim's shebang searches PATH.&#10;if [ ! -x &quot;$NODE_BINARY&quot; ]; then&#10; if [ -f &quot;${PROJECT_DIR}/.xcode.env&quot; ]; then&#10; . &quot;${PROJECT_DIR}/.xcode.env&quot;&#10; fi&#10; if [ -f &quot;${PROJECT_DIR}/.xcode.env.local&quot; ]; then&#10; . &quot;${PROJECT_DIR}/.xcode.env.local&quot;&#10; fi&#10;fi&#10;if [ ! -x &quot;$NODE_BINARY&quot; ]; then&#10; RN_FIND=&quot;&quot;&#10; if [ -n &quot;$REACT_NATIVE_PATH&quot; ] &amp;&amp; [ -f &quot;$REACT_NATIVE_PATH/scripts/find-node-for-xcode.sh&quot; ]; then&#10; RN_FIND=&quot;$REACT_NATIVE_PATH/scripts/find-node-for-xcode.sh&quot;&#10; elif [ -f &quot;${PROJECT_DIR}/../node_modules/react-native/scripts/find-node-for-xcode.sh&quot; ]; then&#10; RN_FIND=&quot;${PROJECT_DIR}/../node_modules/react-native/scripts/find-node-for-xcode.sh&quot;&#10; fi&#10; if [ -n &quot;$RN_FIND&quot; ]; then&#10; NODE_BINARY=$(/bin/bash -c '. &quot;$1&quot; &gt;/dev/null 2&gt;&amp;1; command -v node' _ &quot;$RN_FIND&quot; || true)&#10; fi&#10;fi&#10;if [ -n &quot;$NODE_BINARY&quot; ] &amp;&amp; [ -x &quot;$NODE_BINARY&quot; ]; then&#10; PATH=&quot;$(dirname &quot;$NODE_BINARY&quot;):$PATH&quot;&#10; export PATH NODE_BINARY&#10; for dir in \&#10; &quot;${PROJECT_DIR}/../node_modules&quot; \&#10; &quot;${PROJECT_DIR}/../node_modules/@bugsee/react-native/node_modules&quot; \&#10; &quot;${PROJECT_DIR}/../../../packages/react-native/node_modules&quot;&#10; do&#10; if [ -f &quot;${dir}/@bugsee/cli/bin/bugsee-cli.js&quot; ]; then&#10; run_cli &quot;$NODE_BINARY&quot; &quot;${dir}/@bugsee/cli/bin/bugsee-cli.js&quot; xcode post-action&#10; exit $?&#10; fi&#10; done&#10;fi&#10;&#10;echo &quot;bugsee-cli: not found under node_modules&quot; &gt;&amp;2&#10;exit 1&#10;">
<EnvironmentBuildable>
<BuildableReference
BuildableIdentifier = "primary"
Expand Down
36 changes: 35 additions & 1 deletion packages/react-native/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,10 @@ Known limits:
hooks and the iOS dSYM Archive action. Release builds then upload their source
maps, and Archives upload their dSYMs, whenever a real token is set.
`uploadSourcemaps: false` and `uploadSymbols: false` turn those uploads off.
`editGradleFiles: false` stops the plugin editing the three Android Gradle
files, for a project whose files are Kotlin DSL (see "refuses" below). Edits
an earlier prebuild made stay, and later changes to `uploadSymbols`,
`nativeCrashReporting` or `gradlePluginVersion` no longer reach those files.
A committed `ios/` (`project.pbxproj` and the shared scheme) or
`android/bugsee.properties` carries the token.

Expand Down Expand Up @@ -270,7 +274,9 @@ with certainty it refuses the prebuild with one error that names the file,
the reason and the fix, and writes nothing. It refuses:

- a Kotlin DSL `settings.gradle.kts`, `build.gradle.kts` or app
`build.gradle.kts`;
`build.gradle.kts` (make the edits by hand, then set
`"editGradleFiles": false` in the plugin options and prebuild again: the
plugin then leaves all three Gradle files alone);
- a Gradle file it cannot read for sure: a string that does not close on its
line, a comment or string still open at the end of the file, braces that do
not balance, or a `/` that could start a slashy string as well as divide;
Expand Down Expand Up @@ -324,6 +330,25 @@ react {
apply from: new File(new File(bugseeDir, "scripts"), "bugsee-sourcemaps.gradle")
```

In a Kotlin DSL `android/app/build.gradle.kts` the same two edits read as
follows (not run by the test suite; check them against your Gradle version):

```kotlin
val bugseeDir = File(
ProcessBuilder("node", "--print", "require.resolve('@bugsee/react-native/package.json')")
.directory(rootDir).start().inputStream.bufferedReader().readText().trim()
).parentFile

react {
hermesCommand.set(
File(File(bugseeDir, "scripts"), if (System.getProperty("os.name").startsWith("Windows")) "hermesc-preserve-js.cmd" else "hermesc-preserve-js.sh").absolutePath
)
}

// At the end of the file.
apply(from = File(File(bugseeDir, "scripts"), "bugsee-sourcemaps.gradle"))
```

The OS is checked when Gradle configures the build, so one `build.gradle`
works on macOS, Linux and Windows. Both launchers run
`scripts/hermesc-preserve-js.js` with `node`, which must be on the `PATH` (as
Expand Down Expand Up @@ -481,6 +506,15 @@ in the build environment (for example `export BUGSEE_APP_TOKEN=…` in
skipped the upload; `BUGSEE_UPLOAD_SOURCEMAPS=false` turns the upload off,
and a failed upload warns without failing the build. Debug builds skip it.

`.xcode.env` and `.xcode.env.local` are read for the token by the Archive
dSYM post-action as well, so a token exported there also reaches Xcode GUI
Archives.

Source maps are uploaded with `sourcesContent`, the source code of your app,
so the dashboard can show it. `BUGSEE_STRIP_SOURCES_CONTENT=true` in the
build environment (iOS and Android) removes it from the uploaded copy; the
map on disk is not touched, and symbolication still works.
Comment thread
coderabbitai[bot] marked this conversation as resolved.

Native iOS frames come from the dSYMs. The config plugin adds an Archive
post-action that uploads them with `bugsee-cli xcode post-action`; a bare app
adds the same post-action to its scheme's Archive action (the example app's
Expand Down
11 changes: 11 additions & 0 deletions packages/react-native/plugin/build/dsym-script.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@ export declare function resolveNativeCliPackageSource(packageJson: string): stri
* Shared with the bare example's scheme (scripts/__tests__/dsym-scheme-post-action.test.ts).
*/
export declare const TOKEN_GUARD: readonly string[];
/**
* Looks for the token in ios/.xcode.env and ios/.xcode.env.local, the files
* the README sends a bare app's `export BUGSEE_APP_TOKEN=...` to for the
* bundle phase. A GUI Archive does not inherit a shell, so the post-action
* reads them itself, and only when no earlier source gave a token. Each file
* is sourced in a subshell that prints the token: a file written for bash, a
* syntax error or an `exit` in it cannot stop this script or change its
* NODE_BINARY or BUGSEE_ENDPOINT, and the later file (.local) wins. Shared
* with the bare example's scheme (scripts/__tests__/dsym-scheme-post-action.test.ts).
*/
export declare const ENV_FILE_TOKEN: readonly string[];
/**
* Relays bugsee-cli output with Xcode's `error:` diagnostics turned into
* `warning: bugsee: ...`, and returns the CLI's exit status. A failed upload
Expand Down
29 changes: 26 additions & 3 deletions packages/react-native/plugin/build/dsym-script.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading