-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
21d9713
commit 5b91276
Showing
10 changed files
with
637 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,33 @@ | ||
# symbolicatecrash | ||
iOS crash 文件符号解析工具 | ||
|
||
## 前提 | ||
|
||
* 安装好 Xcode | ||
* 将需要被解析的崩溃文件以 '.crash' 作为后缀进行保存 | ||
* 将同名的 dSYM 文件,放在同一文件夹下 | ||
|
||
如: | ||
|
||
``` | ||
/path/to/ | ||
├── mycrash.crash | ||
├── mycrash.dSYM | ||
``` | ||
## 使用方法 | ||
|
||
`$ ./symbolicatecrash path/to/mycrash.crash` | ||
|
||
解析成功后,将在同一文件夹下生成 `mycrash-symbolicated.crash` 文件 | ||
|
||
## 提示 | ||
|
||
本工具使用了 Xcode 自带工具 `symbolicatecrash`,目录为: | ||
|
||
> /Applications/Xcode.app/Contents/SharedFrameworks/DVTFoundation.framework/Versions/A/Resources/symbolicatecrash | ||
若后续该工具路径发生变化,使用下方命令进行查找: | ||
|
||
`$ find /Applications/Xcode.app -name symbolicatecrash -type f` | ||
|
||
然后在源码中替换新的路径,重新编译即可 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
// | ||
// Shell.swift | ||
// BinaryBuild | ||
// | ||
// Created by Zhen,Lintie on 2020/4/17. | ||
// | ||
|
||
import Foundation | ||
|
||
struct ShellResult { | ||
var status: Int | ||
var output: String | ||
var error: String | ||
} | ||
|
||
enum ShellCommand { | ||
|
||
case symbolicatecrash | ||
case ls | ||
case cp | ||
case rm | ||
case mkdir | ||
|
||
var path: String { | ||
switch self { | ||
case .symbolicatecrash: | ||
return "/Applications/Xcode.app/Contents/SharedFrameworks/DVTFoundation.framework/Versions/A/Resources/symbolicatecrash" | ||
case .ls: | ||
return "/bin/ls" | ||
case .cp: | ||
return "/bin/cp" | ||
case .rm: | ||
return "/bin/rm" | ||
case .mkdir: | ||
return "/bin/mkdir" | ||
} | ||
} | ||
|
||
func isValid() -> Bool { | ||
return false | ||
} | ||
|
||
} | ||
|
||
private func getOutputString(_ pipe: Pipe) -> String { | ||
var output = "" | ||
var outputData: Data? | ||
if #available(OSX 10.15.4, *) { | ||
outputData = try? pipe.fileHandleForReading.readToEnd() | ||
} else { | ||
outputData = pipe.fileHandleForReading.readDataToEndOfFile() | ||
} | ||
if let data = outputData, let string = String(data: data, encoding: .utf8) { | ||
output = string.trimmingCharacters(in: .whitespacesAndNewlines) | ||
} | ||
return output | ||
} | ||
|
||
@discardableResult | ||
func run(_ cmd: String, _ args: [String] = [], environment: [String: String]? = nil, printError: Bool = true) -> ShellResult { | ||
let task = Process() | ||
task.launchPath = cmd | ||
if !args.isEmpty { | ||
task.arguments = args | ||
} | ||
if let environment = environment { | ||
task.environment = env.merging(environment) { | ||
$1 | ||
} | ||
} | ||
// print("Process launch") | ||
|
||
let outputPipe = Pipe() | ||
task.standardOutput = outputPipe | ||
|
||
let errorPipe = Pipe() | ||
task.standardError = errorPipe | ||
|
||
task.launch() | ||
|
||
let output = getOutputString(outputPipe) | ||
let error = getOutputString(errorPipe) | ||
|
||
task.waitUntilExit() | ||
|
||
let status = Int(task.terminationStatus) | ||
|
||
if status != 0, error.count > 0 { | ||
if printError { | ||
print(error) | ||
} | ||
} else { | ||
print(output) | ||
} | ||
|
||
|
||
// print("Process end \(cmd)") | ||
|
||
return ShellResult(status: status, output: output, error: error) | ||
} | ||
|
||
@discardableResult | ||
func run(_ cmd: ShellCommand, _ arguments: [String] = [], environment: [String: String]? = nil, printError: Bool = true) -> ShellResult { | ||
return run(cmd.path, arguments, environment: environment, printError: printError) | ||
} | ||
|
||
@discardableResult | ||
func ls(_ arguments: [String] = []) -> ShellResult { | ||
run(.ls, arguments) | ||
} | ||
|
||
@discardableResult | ||
func cpDir(_ fromPath: String, _ toPath: String) -> ShellResult { | ||
run(.cp, ["-r", fromPath, toPath]) | ||
} | ||
|
||
@discardableResult | ||
func rmDir(_ path: String) -> ShellResult { | ||
run(.rm, ["-rf", path], printError: false) | ||
} | ||
|
||
|
||
|
Oops, something went wrong.