-
Notifications
You must be signed in to change notification settings - Fork 17
/
upload_dsym.py
45 lines (36 loc) · 1.66 KB
/
upload_dsym.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
"""
Python script that zips and uploads a dSYM file package to Rollbar
during an iOS app's build process.
For instructions on setting up this script for your app in Xcode, see
the README at https://github.com/rollbar/rollbar-apple/blob/master/README.md.
"""
import os
import subprocess
import zipfile
if (os.environ['DEBUG_INFORMATION_FORMAT'] != 'dwarf-with-dsym' or
os.environ['EFFECTIVE_PLATFORM_NAME'] == '-iphonesimulator'):
exit(0)
ACCESS_TOKEN = 'POST_SERVER_ITEM_ACCESS_TOKEN'
dsym_file_path = os.path.join(os.environ['DWARF_DSYM_FOLDER_PATH'],
os.environ['DWARF_DSYM_FILE_NAME'])
zip_location = '%s.zip' % (dsym_file_path)
os.chdir(os.environ['DWARF_DSYM_FOLDER_PATH'])
with zipfile.ZipFile(zip_location, 'w', zipfile.ZIP_DEFLATED) as zipf:
for root, dirs, files in os.walk(os.environ['DWARF_DSYM_FILE_NAME']):
zipf.write(root)
for f in files:
zipf.write(os.path.join(root, f))
# You may need to change the following path to match your application
# settings and Xcode version
plist_command = '/usr/libexec/PlistBuddy -c "Print :CFBundleVersion" "%s"'
p = subprocess.Popen(plist_command % os.environ['PRODUCT_SETTINGS_PATH'],
stdout=subprocess.PIPE, shell=True)
stdout, stderr = p.communicate()
version = stdout.strip()
curl_command = ('curl -X POST "https://api.rollbar.com/api/1/dsym" '
'-F access_token=%s -F version=%s -F bundle_identifier="%s" '
'-F dsym=@"%s"')
p = subprocess.Popen(curl_command % (ACCESS_TOKEN, version,
os.environ['PRODUCT_BUNDLE_IDENTIFIER'], zip_location),
shell=True)
p.communicate()