diff --git a/Objective-C/DSYMTools.xcodeproj/project.xcworkspace/xcuserdata/answer.xcuserdatad/UserInterfaceState.xcuserstate b/Objective-C/DSYMTools.xcodeproj/project.xcworkspace/xcuserdata/answer.xcuserdatad/UserInterfaceState.xcuserstate index ce16944..9aba699 100644 Binary files a/Objective-C/DSYMTools.xcodeproj/project.xcworkspace/xcuserdata/answer.xcuserdatad/UserInterfaceState.xcuserstate and b/Objective-C/DSYMTools.xcodeproj/project.xcworkspace/xcuserdata/answer.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/Objective-C/DSYMTools/Controller/MainWindowViewController.m b/Objective-C/DSYMTools/Controller/MainWindowViewController.m index 63b532a..b09c390 100755 --- a/Objective-C/DSYMTools/Controller/MainWindowViewController.m +++ b/Objective-C/DSYMTools/Controller/MainWindowViewController.m @@ -86,22 +86,31 @@ - (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]; } @@ -109,44 +118,49 @@ - (void)handleArchiveFileWithPath:(NSArray *)archiveFilePaths { /** * 从 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; } } @@ -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; } @@ -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; @@ -399,6 +422,10 @@ - (BOOL)performDragOperation:(id )sender NSLog(@"%@", filePath); [archiveFilePaths addObject:filePath]; } + + if([filePath.pathExtension isEqualToString:@"dSYM"]){ + [archiveFilePaths addObject:filePath]; + } } if(archiveFilePaths.count == 0){ diff --git a/Objective-C/DSYMTools/Info.plist b/Objective-C/DSYMTools/Info.plist index 7fc9eb1..5b07d67 100644 --- a/Objective-C/DSYMTools/Info.plist +++ b/Objective-C/DSYMTools/Info.plist @@ -17,7 +17,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.0.4 + 1.0.5 CFBundleSignature ???? CFBundleVersion diff --git a/Objective-C/DSYMTools/Model/ArchiveInfo.h b/Objective-C/DSYMTools/Model/ArchiveInfo.h index a86c1b4..4d75f55 100644 --- a/Objective-C/DSYMTools/Model/ArchiveInfo.h +++ b/Objective-C/DSYMTools/Model/ArchiveInfo.h @@ -7,6 +7,17 @@ // #import + +/** + * 文件类型 + */ +typedef NS_ENUM(NSInteger, ArchiveFileType){ + // archive 文件 + ArchiveFileTypeXCARCHIVE = 1, + //dsym 文件 + ArchiveFileTypeDSYM = 2 +}; + @class UUIDInfo; @interface ArchiveInfo : NSObject @@ -36,4 +47,9 @@ */ @property (copy) NSArray *uuidInfos; +/** + * 文件类型 + */ +@property (assign) ArchiveFileType archiveFileType; + @end diff --git a/README.md b/README.md index 39d8e0b..fd607cd 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ #更新: +###Version 1.0.5 2016-11-28 +1.支持拖入 dSYM 文件。 ###Version 1.0.4 2016-11-08 1.使用 Objective-C 重写应用。 2.建议都使用此版本。