forked from inket/MacSymbolicator
-
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.
Merge pull request inket#22 from inket/multi-target-support
Multi target support
- Loading branch information
Showing
114 changed files
with
5,912 additions
and
3,527 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
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 |
---|---|---|
|
@@ -6,5 +6,3 @@ file_length: 500 | |
disabled_rules: | ||
- type_body_length | ||
- function_body_length | ||
- type_name | ||
- variable_name |
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
This file was deleted.
Oops, something went wrong.
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,162 @@ | ||
// | ||
// InputCoordinator.swift | ||
// MacSymbolicator | ||
// | ||
|
||
import Foundation | ||
|
||
protocol InputCoordinatorDelegate: AnyObject { | ||
func inputCoordinator(_ inputCoordinator: InputCoordinator, receivedNewInput newInput: Any?) | ||
} | ||
|
||
class InputCoordinator { | ||
let crashFileDropZone = DropZone( | ||
fileTypes: [".crash", ".txt"], | ||
allowsMultipleFiles: false, | ||
text: "Drop Crash Report or Sample", | ||
activatesAppAfterDrop: true | ||
) | ||
|
||
let dsymFilesDropZone = DropZone( | ||
fileTypes: [".dSYM"], | ||
allowsMultipleFiles: true, | ||
text: "Drop App DSYMs", | ||
detailText: "(if not found automatically)", | ||
activatesAppAfterDrop: true | ||
) | ||
|
||
private(set) var crashFile: CrashFile? | ||
private(set) var dsymFiles: [DSYMFile] = [] | ||
|
||
private var isSearchingForDSYMs = false | ||
|
||
weak var delegate: InputCoordinatorDelegate? | ||
|
||
let logController = LogController() | ||
|
||
private var expectedDSYMUUIDs: Set<String> { | ||
guard let crashFile = crashFile else { return Set<String>() } | ||
|
||
return Set<String>(crashFile.uuidsForSymbolication.map { $0.pretty }) | ||
} | ||
|
||
private var foundDSYMUUIDs: Set<String> { | ||
let addedDSYMUUIDs = dsymFiles.flatMap { $0.uuids.values }.map { $0.pretty } | ||
return expectedDSYMUUIDs.intersection(addedDSYMUUIDs) | ||
} | ||
|
||
private var remainingDSYMUUIDs: Set<String> { | ||
expectedDSYMUUIDs.subtracting(foundDSYMUUIDs) | ||
} | ||
|
||
init() { | ||
crashFileDropZone.delegate = self | ||
dsymFilesDropZone.delegate = self | ||
} | ||
|
||
func acceptCrashFile(url fileURL: URL) -> Bool { | ||
crashFileDropZone.acceptFile(url: fileURL) | ||
} | ||
|
||
func acceptDSYMFile(url fileURL: URL) -> Bool { | ||
dsymFilesDropZone.acceptFile(url: fileURL) | ||
} | ||
|
||
func startSearchForDSYMs() { | ||
guard let crashFile = crashFile else { return } | ||
|
||
let remainingUUIDs = Array(remainingDSYMUUIDs) | ||
|
||
guard !remainingUUIDs.isEmpty else { | ||
updateDSYMDetailText() | ||
return | ||
} | ||
|
||
isSearchingForDSYMs = true | ||
updateDSYMDetailText() | ||
|
||
DSYMSearch.search( | ||
forUUIDs: remainingUUIDs, | ||
crashFileDirectory: crashFile.path.deletingLastPathComponent().path, | ||
logHandler: logController.addLogMessages, | ||
callback: { [weak self] finished, results in | ||
DispatchQueue.main.async { | ||
results?.forEach { dsymResult in | ||
let dsymURL = URL(fileURLWithPath: dsymResult.path) | ||
self?.dsymFilesDropZone.acceptFile(url: dsymURL) | ||
} | ||
|
||
if finished { | ||
self?.isSearchingForDSYMs = false | ||
} | ||
|
||
self?.updateDSYMDetailText() | ||
} | ||
} | ||
) | ||
} | ||
|
||
func updateCrashDetailText() { | ||
guard crashFile != nil else { | ||
crashFileDropZone.detailText = "" | ||
return | ||
} | ||
|
||
let expectedCount = expectedDSYMUUIDs.count | ||
switch expectedCount { | ||
case 0: | ||
crashFileDropZone.detailText = "(Symbolication not needed)" | ||
case 1: | ||
crashFileDropZone.detailText = "(1 DSYM necessary)" | ||
default: | ||
crashFileDropZone.detailText = "(\(expectedCount) DSYMs necessary)" | ||
} | ||
} | ||
|
||
func updateDSYMDetailText() { | ||
guard crashFile != nil else { | ||
dsymFilesDropZone.detailText = "(if not found automatically)" | ||
return | ||
} | ||
|
||
guard !expectedDSYMUUIDs.isEmpty else { | ||
dsymFilesDropZone.detailText = "" | ||
return | ||
} | ||
|
||
let prefix = isSearchingForDSYMs ? "Searching…" : "Found" | ||
let count = "\(foundDSYMUUIDs.count)/\(expectedDSYMUUIDs.count)" | ||
|
||
dsymFilesDropZone.detailText = "\(prefix) \(count)" | ||
} | ||
} | ||
|
||
extension InputCoordinator: DropZoneDelegate { | ||
func receivedFiles(dropZone: DropZone, fileURLs: [URL]) -> [URL] { | ||
if dropZone == crashFileDropZone, let fileURL = fileURLs.last { | ||
crashFile = CrashFile(path: fileURL) | ||
|
||
logController.resetLogs() | ||
updateCrashDetailText() | ||
|
||
delegate?.inputCoordinator(self, receivedNewInput: crashFile) | ||
|
||
if crashFile != nil { | ||
startSearchForDSYMs() | ||
} | ||
|
||
return fileURLs | ||
} else if dropZone == dsymFilesDropZone { | ||
let dsymFiles = fileURLs.flatMap { DSYMFile.dsymFiles(from: $0) } | ||
self.dsymFiles.append(contentsOf: dsymFiles) | ||
|
||
updateDSYMDetailText() | ||
|
||
delegate?.inputCoordinator(self, receivedNewInput: dsymFiles) | ||
|
||
return dsymFiles.map { $0.path } | ||
} | ||
|
||
return [] | ||
} | ||
} |
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,47 @@ | ||
// | ||
// LogController.swift | ||
// MacSymbolicator | ||
// | ||
|
||
import Cocoa | ||
|
||
protocol LogControllerDelegate: AnyObject { | ||
func logController(_ controller: LogController, logsUpdated logMessages: [String]) | ||
} | ||
|
||
class LogController: NSObject { | ||
private let textWindowController = TextWindowController(title: "Logs") | ||
|
||
weak var delegate: LogControllerDelegate? | ||
|
||
private var logMessages = [String]() { | ||
didSet { | ||
delegate?.logController(self, logsUpdated: logMessages) | ||
|
||
// Update the text here so that if the window is already open, the text gets updated | ||
DispatchQueue.main.async { | ||
self.textWindowController.text = self.logMessages.joined(separator: "\n") | ||
} | ||
} | ||
} | ||
|
||
@objc func viewLogs() { | ||
textWindowController.showWindow() | ||
} | ||
|
||
func addLogMessage(_ message: String) { | ||
logMessages.append(message) | ||
} | ||
|
||
func addLogMessages(_ newMessages: [String]) { | ||
logMessages.append(contentsOf: newMessages) | ||
} | ||
|
||
func merge(_ logController: LogController) { | ||
logMessages.append(contentsOf: logController.logMessages) | ||
} | ||
|
||
func resetLogs() { | ||
logMessages = [] | ||
} | ||
} |
Oops, something went wrong.