Skip to content

Instantly share code, notes, and snippets.

@cellularmitosis
Last active February 7, 2022 18:00
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cellularmitosis/37782a684ec83e1ce623ff4cc6335b7b to your computer and use it in GitHub Desktop.
Save cellularmitosis/37782a684ec83e1ce623ff4cc6335b7b to your computer and use it in GitHub Desktop.

Wrapper script for Crashlytics' dSYMs uploading tool

Crashlytics has a dSYM uploading tool, but it is cumbersome to use (requires command-line params).

Here is a script which crawls your Xcode Archives directory and uploads all of dSYMs it finds.

Be sure to edit the paths to the upload-symbols tool and your GoogleService-Info.plist file.

#!/usr/bin/env python3
# crawl-dsyms.py: crawl your Xcode archives and upload any outstanding dsyms to crashlytics.
# Copyright 2021 Jason Pepas and ibble.io
# Released under the terms of the MIT license
# See https://opensource.org/licenses/MIT
import os
# Configurables:
# path to the 'upload_symbols' command.
upload_symbols_path = os.getenv('HOME') + "/MYAPP/Pods/FirebaseCrashlytics/upload-symbols"
# path to your Google plist file:
plist_path = os.getenv('HOME') + "/MYAPP/GoogleService-Info.plist"
# path to the Xcode Archives directory:
archives_path = os.getenv('HOME') + "/Library/Developer/Xcode/Archives"
# ----
import os.path
import sys
import subprocess
import time
YELLOW = '\033[93m'
RED = '\033[91m'
NORMAL = '\033[0m'
if __name__ == "__main__":
os.chdir(archives_path)
# e.g. ['2021-05-04', '2021-05-03'], etc.
date_dirs = sorted(os.listdir(), reverse=True)
for date_dir in date_dirs:
if not os.path.isdir(date_dir):
continue
os.chdir(date_dir)
# e.g. ['fooapp 2021-05-12 10.32.17.xcarchive', 'fooapp 2021-05-11 11.59.29.xcarchive'], etc.
archive_dirs = sorted(os.listdir(), reverse=True)
for archive_dir in archive_dirs:
if not os.path.isdir(archive_dir):
continue
os.chdir(archive_dir)
os.chdir('dSYMs')
# upload the dsyms if this dir hasn't already been crawled:
if not os.path.exists('.crawled'):
cmd = "%s -d -p ios -gsp '%s' . >.crawl.log 2>&1" % (upload_symbols_path, plist_path)
print("Processing '%s/%s/%s'" % (archives_path, date_dir, archive_dir))
print(" %s" % (cmd))
then = time.time()
try:
subprocess.check_call(cmd, shell=True)
except:
sys.stderr.write(
"\n%sException caught%s, dumping log file at '%s/%s/%s/dSYMs/.crawl.log':\n"
% (RED, NORMAL, archives_path, date_dir, archive_dir)
)
sys.stderr.write('---- LOG FILE ----\n')
sys.stderr.write(open('.crawl.log', 'r').read())
sys.stderr.write('---- END LOG FILE ----\n\n')
raise
now = time.time()
elapsed = now - then
if elapsed < 1.0:
sys.stderr.write(
"%sWarning:%s upload-symbols ran in less than 1 second (it likely didn't do anything).\n"
% (YELLOW, NORMAL)
)
else:
open('.crawled', 'a').close()
os.chdir('../..')
os.chdir('..')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment