Skip to content

Commit e31c493

Browse files
antonisclaude
andcommitted
refactor(ios): Gate verbose dSYM status messages behind SENTRY_DSYM_DEBUG
Add _sentry_dsym_log() helper that only prints when SENTRY_DSYM_DEBUG is set. Per-attempt "not ready" messages (dSYM not found, DWARF empty, etc.) are now debug-only to reduce noise in normal builds. Success messages and timeout warnings remain always visible. Update tests to pass SENTRY_DSYM_DEBUG=true when asserting on the per-attempt debug messages. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 2daf568 commit e31c493

2 files changed

Lines changed: 21 additions & 18 deletions

File tree

packages/core/scripts/sentry-xcode-debug-files.sh

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@ EXTRA_ARGS="$SENTRY_CLI_EXTRA_ARGS $SENTRY_CLI_DEBUG_FILES_UPLOAD_EXTRA_ARGS $IN
5858

5959
UPLOAD_DEBUG_FILES="\"$SENTRY_CLI_EXECUTABLE\" debug-files upload $EXTRA_ARGS \"$DWARF_DSYM_FOLDER_PATH\""
6060

61+
# Print a message only when SENTRY_DSYM_DEBUG is set
62+
_sentry_dsym_log() {
63+
if [ -n "${SENTRY_DSYM_DEBUG}" ]; then
64+
echo "$1"
65+
fi
66+
}
67+
6168
# Check if dSYM files are fully generated and ready to upload.
6269
# Returns 0 (ready) or 1 (not ready yet), printing a status message in either case.
6370
_sentry_check_dsym_ready() {
@@ -67,14 +74,14 @@ _sentry_check_dsym_ready() {
6774
local max_attempts="$4"
6875

6976
if [ ! -d "$dsym_folder" ]; then
70-
echo "dSYM folder does not exist yet: $dsym_folder (attempt $attempt/$max_attempts)"
77+
_sentry_dsym_log "dSYM folder does not exist yet: $dsym_folder (attempt $attempt/$max_attempts)"
7178
return 1
7279
fi
7380

7481
local dsym_count
7582
dsym_count=$(find "$dsym_folder" -name "*.dSYM" -type d 2>/dev/null | wc -l | tr -d ' ')
7683
if [ "$dsym_count" -eq 0 ]; then
77-
echo "No dSYM bundles found yet in $dsym_folder (attempt $attempt/$max_attempts)"
84+
_sentry_dsym_log "No dSYM bundles found yet in $dsym_folder (attempt $attempt/$max_attempts)"
7885
return 1
7986
fi
8087

@@ -90,34 +97,34 @@ _sentry_check_dsym_ready() {
9097
return 0
9198
fi
9299
done
93-
echo "Found dSYM bundle(s) but none have complete DWARF content yet (attempt $attempt/$max_attempts)"
100+
_sentry_dsym_log "Found dSYM bundle(s) but none have complete DWARF content yet (attempt $attempt/$max_attempts)"
94101
return 1
95102
fi
96103

97104
# DWARF_DSYM_FILE_NAME set: verify the main app dSYM is complete
98105
local main_dsym="$dsym_folder/$dsym_file_name"
99106
if [ ! -d "$main_dsym" ]; then
100-
echo "Main app dSYM not found yet: $dsym_file_name (attempt $attempt/$max_attempts)"
107+
_sentry_dsym_log "Main app dSYM not found yet: $dsym_file_name (attempt $attempt/$max_attempts)"
101108
return 1
102109
fi
103110

104111
local dwarf_dir="$main_dsym/Contents/Resources/DWARF"
105112
if [ ! -d "$dwarf_dir" ]; then
106-
echo "Main app dSYM structure incomplete (missing DWARF directory): $dsym_file_name (attempt $attempt/$max_attempts)"
113+
_sentry_dsym_log "Main app dSYM structure incomplete (missing DWARF directory): $dsym_file_name (attempt $attempt/$max_attempts)"
107114
return 1
108115
fi
109116

110117
local dwarf_files
111118
dwarf_files=$(find "$dwarf_dir" -type f 2>/dev/null | head -1)
112119
if [ -z "$dwarf_files" ]; then
113-
echo "Main app dSYM DWARF directory is empty: $dsym_file_name (attempt $attempt/$max_attempts)"
120+
_sentry_dsym_log "Main app dSYM DWARF directory is empty: $dsym_file_name (attempt $attempt/$max_attempts)"
114121
return 1
115122
fi
116123

117124
local dwarf_size
118125
dwarf_size=$(find "$dwarf_dir" -type f -size +0 2>/dev/null | head -1)
119126
if [ -z "$dwarf_size" ]; then
120-
echo "Main app dSYM DWARF binary is empty (still being written): $dsym_file_name (attempt $attempt/$max_attempts)"
127+
_sentry_dsym_log "Main app dSYM DWARF binary is empty (still being written): $dsym_file_name (attempt $attempt/$max_attempts)"
121128
return 1
122129
fi
123130

@@ -148,17 +155,9 @@ wait_for_dsym_files() {
148155
echo "Checking for dSYM files in: $DWARF_DSYM_FOLDER_PATH"
149156

150157
# Debug information to help diagnose issues
151-
if [ -n "${SENTRY_DSYM_DEBUG}" ]; then
152-
echo "DEBUG: DWARF_DSYM_FOLDER_PATH=$DWARF_DSYM_FOLDER_PATH"
153-
echo "DEBUG: DWARF_DSYM_FILE_NAME=$DWARF_DSYM_FILE_NAME"
154-
echo "DEBUG: PRODUCT_NAME=$PRODUCT_NAME"
155-
if [ -d "$DWARF_DSYM_FOLDER_PATH" ]; then
156-
echo "DEBUG: Contents of dSYM folder:"
157-
ls -la "$DWARF_DSYM_FOLDER_PATH" 2>/dev/null || echo "Cannot list folder"
158-
else
159-
echo "DEBUG: dSYM folder does not exist yet"
160-
fi
161-
fi
158+
_sentry_dsym_log "DEBUG: DWARF_DSYM_FOLDER_PATH=$DWARF_DSYM_FOLDER_PATH"
159+
_sentry_dsym_log "DEBUG: DWARF_DSYM_FILE_NAME=$DWARF_DSYM_FILE_NAME"
160+
_sentry_dsym_log "DEBUG: PRODUCT_NAME=$PRODUCT_NAME"
162161

163162
while [ $attempt -le $max_attempts ]; do
164163
if _sentry_check_dsym_ready "$DWARF_DSYM_FOLDER_PATH" "$DWARF_DSYM_FILE_NAME" "$attempt" "$max_attempts"; then

packages/core/test/scripts/sentry-xcode-scripts.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ describe('sentry-xcode-debug-files.sh', () => {
236236
DWARF_DSYM_FILE_NAME: 'MainApp.app.dSYM', // Looking for this specific one
237237
SENTRY_DSYM_WAIT_MAX_ATTEMPTS: '2',
238238
SENTRY_DSYM_WAIT_INTERVAL: '1',
239+
SENTRY_DSYM_DEBUG: 'true',
239240
MOCK_CLI_EXIT_CODE: '0',
240241
});
241242

@@ -259,6 +260,7 @@ describe('sentry-xcode-debug-files.sh', () => {
259260
DWARF_DSYM_FILE_NAME: 'IncompleteApp.app.dSYM',
260261
SENTRY_DSYM_WAIT_MAX_ATTEMPTS: '2',
261262
SENTRY_DSYM_WAIT_INTERVAL: '1',
263+
SENTRY_DSYM_DEBUG: 'true',
262264
MOCK_CLI_EXIT_CODE: '0',
263265
});
264266

@@ -282,6 +284,7 @@ describe('sentry-xcode-debug-files.sh', () => {
282284
DWARF_DSYM_FILE_NAME: 'WritingApp.app.dSYM',
283285
SENTRY_DSYM_WAIT_MAX_ATTEMPTS: '2',
284286
SENTRY_DSYM_WAIT_INTERVAL: '1',
287+
SENTRY_DSYM_DEBUG: 'true',
285288
MOCK_CLI_EXIT_CODE: '0',
286289
});
287290

@@ -297,6 +300,7 @@ describe('sentry-xcode-debug-files.sh', () => {
297300
DWARF_DSYM_FOLDER_PATH: nonExistentPath,
298301
SENTRY_DSYM_WAIT_MAX_ATTEMPTS: '2',
299302
SENTRY_DSYM_WAIT_INTERVAL: '1',
303+
SENTRY_DSYM_DEBUG: 'true',
300304
MOCK_CLI_EXIT_CODE: '0',
301305
});
302306

0 commit comments

Comments
 (0)