Skip to content

Commit

Permalink
#1.0.5 支持拖入 dSYM 文件。
Browse files Browse the repository at this point in the history
  • Loading branch information
answer committed Nov 27, 2016
1 parent 5458c61 commit 7a2eeab
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 42 deletions.
Binary file not shown.
109 changes: 68 additions & 41 deletions Objective-C/DSYMTools/Controller/MainWindowViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -86,67 +86,81 @@ - (void)windowDidLoad{
/**
* 处理给定archive文件路径,获取 archiveinfo 对象
*
* @param archiveFilePaths archvie 文件路径
* @param filePaths archvie 文件路径
*/
- (void)handleArchiveFileWithPath:(NSArray *)archiveFilePaths {
- (void)handleArchiveFileWithPath:(NSArray *)filePaths {
_archiveFilesInfo = [NSMutableArray arrayWithCapacity:1];
for(NSString *archivePath in archiveFilePaths){
for(NSString *filePath in filePaths){
ArchiveInfo *archiveInfo = [[ArchiveInfo alloc] init];
archiveInfo.archiveFilePath = archivePath;
NSString *fileName = archivePath.lastPathComponent;
//如果不是 xcarchive 文件路径则继续循环
if (![fileName hasSuffix:@".xcarchive"]){

NSString *fileName = filePath.lastPathComponent;
//支持 xcarchive 文件和 dSYM 文件。
if ([fileName hasSuffix:@".xcarchive"]){
archiveInfo.archiveFilePath = filePath;
archiveInfo.archiveFileName = fileName;
archiveInfo.archiveFileType = ArchiveFileTypeXCARCHIVE;
[self formatArchiveInfo:archiveInfo];
}else if([fileName hasSuffix:@".dSYM"]){
archiveInfo.dSYMFilePath = filePath;
archiveInfo.dSYMFileName = fileName;
archiveInfo.archiveFileType = ArchiveFileTypeDSYM;
[self formatDSYM:archiveInfo];
}else{
continue;
}
archiveInfo.archiveFileName = fileName;

[_archiveFilesInfo addObject:archiveInfo];
}
[self extraDSYMInfoFromArchiveInfo:_archiveFilesInfo];

[self.archiveFilesTableView reloadData];
}

/**
* 从 archive 文件中获取 dsym 文件信息
*
* @param archiveFilesPath archive info 对象
* @param archiveInfo archive info 对象
*/
- (void)extraDSYMInfoFromArchiveInfo:(NSArray *)archiveFilesPath {
- (void)formatArchiveInfo:(ArchiveInfo *)archiveInfo{
NSString *dSYMsDirectoryPath = [NSString stringWithFormat:@"%@/dSYMs", archiveInfo.archiveFilePath];
NSArray *keys = @[@"NSURLPathKey",@"NSURLFileResourceTypeKey",@"NSURLIsDirectoryKey",@"NSURLIsPackageKey"];
NSArray *dSYMSubFiles= [[NSFileManager defaultManager] contentsOfDirectoryAtURL:[NSURL fileURLWithPath:dSYMsDirectoryPath] includingPropertiesForKeys:keys options:(NSDirectoryEnumerationSkipsHiddenFiles | NSDirectoryEnumerationSkipsPackageDescendants) error:nil];
for(NSURL *fileURLs in dSYMSubFiles){
if ([[fileURLs.relativePath lastPathComponent] hasSuffix:@"dSYM"]){
archiveInfo.dSYMFilePath = fileURLs.relativePath;
archiveInfo.dSYMFileName = fileURLs.relativePath.lastPathComponent;
}
}
[self formatDSYM:archiveInfo];

}

/**
* 根据 dSYM 文件获取 UUIDS。
* @param archiveInfo
*/
- (void)formatDSYM:(ArchiveInfo *)archiveInfo{
//匹配 () 里面内容
NSString *pattern = @"(?<=\\()[^}]*(?=\\))";
NSRegularExpression *reg = [NSRegularExpression regularExpressionWithPattern:pattern options:0 error:nil];

for(ArchiveInfo *archiveInfo in archiveFilesPath){
NSString *dSYMsDirectoryPath = [NSString stringWithFormat:@"%@/dSYMs", archiveInfo.archiveFilePath];
NSArray *keys = @[@"NSURLPathKey",@"NSURLFileResourceTypeKey",@"NSURLIsDirectoryKey",@"NSURLIsPackageKey"];
NSArray *dSYMSubFiles= [[NSFileManager defaultManager] contentsOfDirectoryAtURL:[NSURL fileURLWithPath:dSYMsDirectoryPath] includingPropertiesForKeys:keys options:(NSDirectoryEnumerationSkipsHiddenFiles | NSDirectoryEnumerationSkipsPackageDescendants) error:nil];
for(NSURL *fileURLs in dSYMSubFiles){
if ([[fileURLs.relativePath lastPathComponent] hasSuffix:@"dSYM"]){
archiveInfo.dSYMFilePath = fileURLs.relativePath;
archiveInfo.dSYMFileName = fileURLs.relativePath.lastPathComponent;
}
NSString *commandString = [NSString stringWithFormat:@"dwarfdump --uuid \"%@\"",archiveInfo.dSYMFilePath];
NSString *uuidsString = [self runCommand:commandString];
NSArray *uuids = [uuidsString componentsSeparatedByString:@"\n"];

NSMutableArray *uuidInfos = [NSMutableArray arrayWithCapacity:1];
for(NSString *uuidString in uuids){
NSArray* match = [reg matchesInString:uuidString options:NSMatchingReportCompletion range:NSMakeRange(0, [uuidString length])];
if (match.count == 0) {
continue;
}
NSString *commandString = [NSString stringWithFormat:@"dwarfdump --uuid \"%@\"",archiveInfo.dSYMFilePath];
NSString *uuidsString = [self runCommand:commandString];
NSArray *uuids = [uuidsString componentsSeparatedByString:@"\n"];

NSMutableArray *uuidInfos = [NSMutableArray arrayWithCapacity:1];
for(NSString *uuidString in uuids){
NSArray* match = [reg matchesInString:uuidString options:NSMatchingReportCompletion range:NSMakeRange(0, [uuidString length])];
if (match.count == 0) {
continue;
}
for (NSTextCheckingResult *result in match) {
NSRange range = [result range];
UUIDInfo *uuidInfo = [[UUIDInfo alloc] init];
uuidInfo.arch = [uuidString substringWithRange:range];
uuidInfo.uuid = [uuidString substringWithRange:NSMakeRange(6, range.location-6-2)];
uuidInfo.executableFilePath = [uuidString substringWithRange:NSMakeRange(range.location+range.length+2, [uuidString length]-(range.location+range.length+2))];
[uuidInfos addObject:uuidInfo];
}
archiveInfo.uuidInfos = uuidInfos;
for (NSTextCheckingResult *result in match) {
NSRange range = [result range];
UUIDInfo *uuidInfo = [[UUIDInfo alloc] init];
uuidInfo.arch = [uuidString substringWithRange:range];
uuidInfo.uuid = [uuidString substringWithRange:NSMakeRange(6, range.location-6-2)];
uuidInfo.executableFilePath = [uuidString substringWithRange:NSMakeRange(range.location+range.length+2, [uuidString length]-(range.location+range.length+2))];
[uuidInfos addObject:uuidInfo];
}
archiveInfo.uuidInfos = uuidInfos;
}
}

Expand Down Expand Up @@ -271,6 +285,11 @@ - (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView{

- (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row{
ArchiveInfo *archiveInfo= _archiveFilesInfo[row];
if(archiveInfo.archiveFileType == ArchiveFileTypeXCARCHIVE){
return archiveInfo.archiveFileName;
}else if(archiveInfo.archiveFileType == ArchiveFileTypeDSYM){
return archiveInfo.dSYMFileName;
}
return archiveInfo.archiveFileName;
}

Expand All @@ -283,7 +302,11 @@ - (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn
if (subviews.count > 0) {
if ([identifier isEqualToString:@"name"]) {
NSTextField *textField = subviews[0];
textField.stringValue = archiveInfo.archiveFileName;
if(archiveInfo.archiveFileType == ArchiveFileTypeXCARCHIVE){
textField.stringValue = archiveInfo.archiveFileName;
}else if(archiveInfo.archiveFileType == ArchiveFileTypeDSYM){
textField.stringValue = archiveInfo.dSYMFileName;
}
}
}
return view;
Expand Down Expand Up @@ -399,6 +422,10 @@ - (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
NSLog(@"%@", filePath);
[archiveFilePaths addObject:filePath];
}

if([filePath.pathExtension isEqualToString:@"dSYM"]){
[archiveFilePaths addObject:filePath];
}
}

if(archiveFilePaths.count == 0){
Expand Down
2 changes: 1 addition & 1 deletion Objective-C/DSYMTools/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0.4</string>
<string>1.0.5</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
16 changes: 16 additions & 0 deletions Objective-C/DSYMTools/Model/ArchiveInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@
//

#import <Foundation/Foundation.h>

/**
* 文件类型
*/
typedef NS_ENUM(NSInteger, ArchiveFileType){
// archive 文件
ArchiveFileTypeXCARCHIVE = 1,
//dsym 文件
ArchiveFileTypeDSYM = 2
};

@class UUIDInfo;

@interface ArchiveInfo : NSObject
Expand Down Expand Up @@ -36,4 +47,9 @@
*/
@property (copy) NSArray<UUIDInfo *> *uuidInfos;

/**
* 文件类型
*/
@property (assign) ArchiveFileType archiveFileType;

@end
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#更新:
###Version 1.0.5 2016-11-28
1.支持拖入 dSYM 文件。
###Version 1.0.4 2016-11-08
1.使用 Objective-C 重写应用。
2.建议都使用此版本。
Expand Down

0 comments on commit 7a2eeab

Please sign in to comment.