Skip to content

Commit

Permalink
Move demo downlaod script to template file
Browse files Browse the repository at this point in the history
  • Loading branch information
zqqf16 committed Jan 27, 2022
1 parent c8f9274 commit fed8e9f
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 31 deletions.
4 changes: 4 additions & 0 deletions SYM.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
B59B326F22E0113100013B67 /* MDHouseArrest.m in Sources */ = {isa = PBXBuildFile; fileRef = B53E2F8522D48383003BC45C /* MDHouseArrest.m */; };
B59B327022E0113300013B67 /* MDInstProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = B5B97AEE22DC737900F5DDF2 /* MDInstProxy.m */; };
B59B327122E0113600013B67 /* MDUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = B53E2F7922D4710C003BC45C /* MDUtil.m */; };
B5AF3E0327A243AC0037AAAD /* template.sh in Resources */ = {isa = PBXBuildFile; fileRef = B5AF3E0227A243AC0037AAAD /* template.sh */; };
B5B97AEF22DC737900F5DDF2 /* MDInstProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = B5B97AEE22DC737900F5DDF2 /* MDInstProxy.m */; };
B5B97AF022DC737900F5DDF2 /* MDInstProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = B5B97AEE22DC737900F5DDF2 /* MDInstProxy.m */; };
B5EC56D227759AE5007EB567 /* ConfigTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5EC56D127759AE5007EB567 /* ConfigTests.swift */; };
Expand Down Expand Up @@ -171,6 +172,7 @@
B56BAA5523A8ECDB00049491 /* MdfindWrapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MdfindWrapper.swift; sourceTree = "<group>"; };
B5847A8C2569419600B674CA /* DeviceContentViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeviceContentViewController.swift; sourceTree = "<group>"; };
B597FE1422DC8A9400BE439A /* FileBrowserViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileBrowserViewController.swift; sourceTree = "<group>"; };
B5AF3E0227A243AC0037AAAD /* template.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; name = template.sh; path = SYM/dSYM/template.sh; sourceTree = SOURCE_ROOT; };
B5B97AED22DC737900F5DDF2 /* MDInstProxy.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MDInstProxy.h; sourceTree = "<group>"; };
B5B97AEE22DC737900F5DDF2 /* MDInstProxy.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MDInstProxy.m; sourceTree = "<group>"; };
B5EC56D127759AE5007EB567 /* ConfigTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConfigTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -403,6 +405,7 @@
children = (
B56BAA4F23A8E8EB00049491 /* DsymManager.swift */,
F49E2D49214BB2D6001A6A88 /* DsymDownloader.swift */,
B5AF3E0227A243AC0037AAAD /* template.sh */,
);
path = Dsym;
sourceTree = "<group>";
Expand Down Expand Up @@ -727,6 +730,7 @@
F40B9DBE2123E32D000DF7C6 /* models.txt in Resources */,
F4CD14631D39D323006BAB2B /* Assets.xcassets in Resources */,
B5F357B522C5E90C00111FF3 /* Localizable.strings in Resources */,
B5AF3E0327A243AC0037AAAD /* template.sh in Resources */,
B56B9B8923A379CE00049491 /* Dsym.storyboard in Resources */,
B5F3579322C5C8EF00111FF3 /* Device.storyboard in Resources */,
B5F3579822C5CAD400111FF3 /* ScriptImporter.storyboard in Resources */,
Expand Down
27 changes: 27 additions & 0 deletions SYM/Dsym/template.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

# Download the .dSYM file to wherever you want.
# SYM can find it automatically.

# Environment variables:
# $1 # original crash file path
# $2 # download directory
# ${APP_NAME} # e.g. im_zorro_sym
# ${UUID} # e.g. E5B0A378-6816-3D90-86FD-2AEF15894A85
# ${BUNDLE_ID} # e.g. im.zorro.sym
# ${APP_VERSION} # e.g. 212 (1.0.1)

# Error handling:
# exit 0 # success
# exit 1 # crash not supported
# exit 2 # download failed

# Examples:
# curl -o $2/${UUID}.zip http://your.server.domain/path/to/${UUID}.zip
# unzip -o "$2/${UUID}.zip" -d "$2/${UUID}"
# for f in "$2/${UUID}/*.dSYM"; do dwarfdump --uuid $f ; done
#

# Tips:
# - curl progress will be shown in the downlaod progress bar
# - run `dwarfdump --uuid` at the end of the script to output the UUID will speed up the indexing process
38 changes: 7 additions & 31 deletions SYM/UI/DownloadScriptViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,37 +56,13 @@ class DownloadScriptViewController: NSViewController {
}

func loadContent() {
let defaultContent = """
#!/bin/bash
# Download the .dSYM file to wherever you want.
# SYM can find it immediately.
# Crash informations
# $1 # original crash file path
# $2 # download directory
# ${APP_NAME} # e.g. im_zorro_sym
# ${UUID} # e.g. E5B0A378-6816-3D90-86FD-2AEF15894A85
# ${BUNDLE_ID} # e.g. im.zorro.sym
# ${APP_VERSION} # e.g. 212 (1.0.1)
# Error handling:
# exit 0 # success
# exit 1 # crash not supported
# exit 2 # download failed"
# Examples:
# curl -o $2/${UUID}.zip http://your.server.domain/path/to/${UUID}.zip
# unzip -o "$2/${UUID}.zip" -d "$2/${UUID}"
# for f in "$2/${UUID}/*.dSYM"; do dwarfdump --uuid $f ; done
#
"""
let saved = try? String(contentsOf: Config.downloadScriptURL, encoding: .utf8)
if saved != nil && saved!.count > 0 {
self.textView.string = saved!
} else {
self.textView.string = defaultContent
let userImportedScript = try? String(contentsOf: Config.downloadScriptURL, encoding: .utf8)
if userImportedScript == nil && userImportedScript!.lengthOfBytes(using: .utf8) > 0 {
self.textView.string = userImportedScript!
return
}

let template = try! String(contentsOf: Bundle.main.url(forResource: "template", withExtension: "sh")!, encoding: .utf8)
self.textView.string = template
}
}

0 comments on commit fed8e9f

Please sign in to comment.