diff --git a/.gitignore b/.gitignore index 8c78cdf..362db9d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,15 @@ +# Created by https://www.gitignore.io/api/xcode,swift,osx,carthage,objective-c + +### Xcode ### # Xcode # +# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore + +## Build generated build/ +DerivedData + +## Various settings *.pbxuser !default.pbxuser *.mode1v3 @@ -10,10 +19,136 @@ build/ *.perspectivev3 !default.perspectivev3 xcuserdata + +## Other *.xccheckout *.moved-aside +*.xcuserstate + + +### Swift ### +# Xcode +# +# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore + +## Build generated +build/ DerivedData + +## Various settings +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +xcuserdata + +## Other +*.xccheckout +*.moved-aside +*.xcuserstate +*.xcscmblueprint + +## Obj-C/Swift specific *.hmap *.ipa + +# CocoaPods +# +# We recommend against adding the Pods directory to your .gitignore. However +# you should judge for yourself, the pros and cons are mentioned at: +# http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control +# +# Pods/ + +# Carthage +# +# Add this line if you want to avoid checking in source code from Carthage dependencies. +# Carthage/Checkouts + +Carthage/Build + + +### OSX ### +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + + +### Carthage ### +# Carthage - A simple, decentralized dependency manager for Cocoa +Carthage.checkout +Carthage.build + +### Objective-C ### +# Xcode +# +# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore + +## Build generated +build/ +DerivedData + +## Various settings +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +xcuserdata + +## Other +*.xccheckout +*.moved-aside *.xcuserstate -*.xcscheme +*.xcscmblueprint + +## Obj-C/Swift specific +*.hmap +*.ipa + +# CocoaPods +# +# We recommend against adding the Pods directory to your .gitignore. However +# you should judge for yourself, the pros and cons are mentioned at: +# http://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control +# +#Pods/ + +# Carthage +# +# Add this line if you want to avoid checking in source code from Carthage dependencies. +# Carthage/Checkouts + +Carthage/Build + +### Objective-C Patch ### +*.xcscmblueprint diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..a012994 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,3 @@ +language: objective-c +xcode_project: ObjectGraph-Xcode.xcodeproj +xcode_scheme: ObjectGraph diff --git a/ObjectGraph-Xcode.xcodeproj/xcshareddata/xcschemes/ObjectGraph.xcscheme b/ObjectGraph-Xcode.xcodeproj/xcshareddata/xcschemes/ObjectGraph.xcscheme new file mode 100644 index 0000000..7dddf67 --- /dev/null +++ b/ObjectGraph-Xcode.xcodeproj/xcshareddata/xcschemes/ObjectGraph.xcscheme @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ObjectGraph.pdf b/ObjectGraph.pdf new file mode 100644 index 0000000..ca75fe8 Binary files /dev/null and b/ObjectGraph.pdf differ diff --git a/ObjectGraph/Info.plist b/ObjectGraph/Info.plist index c1314c8..7fa1278 100644 --- a/ObjectGraph/Info.plist +++ b/ObjectGraph/Info.plist @@ -24,9 +24,19 @@ 1 DVTPlugInCompatibilityUUIDs + 7FDF5C7A-131F-4ABB-9EDC-8C5F8F0B8A90 + E969541F-E6F9-4D25-8158-72DC3545A6C6 + 9F75337B-21B4-4ADC-B558-F9CADF7073A7 A16FF353-8441-459E-A50C-B071F53F51B7 C4A681B0-4A26-480E-93EC-1218098B9AA0 AD68E85B-441B-4301-B564-A45E4919A6AD + AABB7188-E14E-4433-AD3B-5CD791EAD9A3 + CC0D0F4F-05B3-431A-8F33-F84AFCB2C651 + 0420B86A-AA43-4792-9ED0-6FE0F2B16A13 + 7265231C-39B4-402C-89E1-16167C4CC990 + F41BD31E-2683-44B8-AE7F-5F09E919790E + ACA8656B-FEA8-4B6D-8E4A-93F4C95C362C + DFFB3951-EB0A-4C09-9DAC-5F2D28CC839C LSMinimumSystemVersion $(MACOSX_DEPLOYMENT_TARGET) diff --git a/ObjectGraph/ObjectGraph.dot b/ObjectGraph/ObjectGraph.dot deleted file mode 100644 index 2741811..0000000 --- a/ObjectGraph/ObjectGraph.dot +++ /dev/null @@ -1,17 +0,0 @@ -digraph G { - node [shape=box]; - "VWKShellHandler" -> "VWKRunOperation"; - "VWKRunOperation" -> {}; - "VWKDocumentationManager" -> {}; - "ObjectGraph" -> "VWKProject"; - "ObjectGraph" -> "VWKWorkspaceManager"; - "ObjectGraph" -> "VWKShellHandler"; - "VWKXCodeConsole" -> {}; - - "ObjectGraph-Prefix" [color=red]; - "ObjectGraph-Prefix" -> "VWKXCodeConsole" [color=red]; - - edge [color=blue, dir=both]; - "VWKProject" -> "VWKWorkspaceManager"; -} - diff --git a/ObjectGraph/ObjectGraph.m b/ObjectGraph/ObjectGraph.m index 7791748..04ab38f 100644 --- a/ObjectGraph/ObjectGraph.m +++ b/ObjectGraph/ObjectGraph.m @@ -47,8 +47,8 @@ @interface ObjectGraph() @property (nonatomic, strong) NSMenuItem *pathItem; @property (nonatomic, copy) NSString *sourceCodePath; @property (nonatomic, copy) TaskBlock getGraphvizExecutablePathBlock; -@property (nonatomic, copy) TaskBlock convertToPNGBlock; -@property (nonatomic, copy) TaskBlock movePNGFileBlock; +@property (nonatomic, copy) TaskBlock convertToPDFBlock; +@property (nonatomic, copy) TaskBlock movePDFFileBlock; @property (nonatomic, copy) TaskBlock moveDOTFileBlock; @property (nonatomic, copy) TaskBlock openBlock; @@ -86,14 +86,16 @@ - (id)initWithBundle:(NSBundle *)plugin [self setDefaultSourceCodePathPath]; [self setupGetGraphvizExecutablePathBlock]; - [self setupConvertToPNGBlock]; - [self setupMovePNGFileBlock]; + [self setupConvertToPDFBlock]; + [self setupMovePDFFileBlock]; [self setupMoveDOTFileBlock]; [self setupOpenBlock]; // Create menu items, initialize UI, etc. - [self addMenuItems]; + [[NSOperationQueue mainQueue] addOperationWithBlock:^{ + [self addMenuItems]; + }]; } return self; } @@ -164,15 +166,15 @@ - (void)selectPath - (NSString *)dotFileName { VWKProject *project = [VWKProject projectForKeyWindow]; - NSString *dotFileName = [project.projectName stringByAppendingString:@".dot"]; + NSString *dotFileName = [project.projectName stringByAppendingPathExtension:@"dot"]; return dotFileName; } -- (NSString *)pngFileName +- (NSString *)pdfFileName { VWKProject *project = [VWKProject projectForKeyWindow]; - NSString *pngFileName = [project.projectName stringByAppendingString:@".png"]; - return pngFileName; + NSString *pdfFileName = [project.projectName stringByAppendingPathExtension:@"pdf"]; + return pdfFileName; } - (NSString *)projectPath @@ -206,36 +208,36 @@ - (void)setupGetGraphvizExecutablePathBlock [VWKShellHandler runShellCommand:shellString withArgs:args directory:strongSelf.sourceCodePath - completion:strongSelf.convertToPNGBlock]; + completion:strongSelf.convertToPDFBlock]; }; } -- (void)setupConvertToPNGBlock +- (void)setupConvertToPDFBlock { __weak __typeof(&*self)weakSelf = self; - self.convertToPNGBlock = ^(NSTask *t, + self.convertToPDFBlock = ^(NSTask *t, NSString *standardOutputString, NSString *standardErrorString){ __strong __typeof(&*weakSelf)strongSelf = weakSelf; if (standardOutputString.length > 0) { NSString *GRAPHVIZ_EXECUTABLE_PATH = [standardOutputString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; [VWKShellHandler runShellCommand:GRAPHVIZ_EXECUTABLE_PATH - withArgs:@[@"-Tpng", strongSelf.dotFileName, @"-o", strongSelf.pngFileName] + withArgs:@[@"-Tpdf", strongSelf.dotFileName, @"-o", strongSelf.pdfFileName] directory:strongSelf.sourceCodePath - completion:strongSelf.movePNGFileBlock]; + completion:strongSelf.movePDFFileBlock]; } }; } -- (void)setupMovePNGFileBlock +- (void)setupMovePDFFileBlock { __weak __typeof(&*self)weakSelf = self; - self.movePNGFileBlock = ^(NSTask *t, + self.movePDFFileBlock = ^(NSTask *t, NSString *standardOutputString, NSString *standardErrorString){ __strong __typeof(&*weakSelf)strongSelf = weakSelf; [VWKShellHandler runShellCommand:[BIN_PATH stringByAppendingPathComponent:MOVE_EXECUTABLE] - withArgs:@[strongSelf.pngFileName, strongSelf.projectPath] + withArgs:@[strongSelf.pdfFileName, strongSelf.projectPath] directory:strongSelf.sourceCodePath completion:strongSelf.moveDOTFileBlock]; }; @@ -263,7 +265,7 @@ - (void)setupOpenBlock NSString *standardErrorString){ __strong __typeof(&*weakSelf)strongSelf = weakSelf; [VWKShellHandler runShellCommand:[USER_BIN_PATH stringByAppendingPathComponent:OPEN_EXECUTABLE] - withArgs:@[strongSelf.pngFileName] + withArgs:@[strongSelf.pdfFileName] directory:strongSelf.projectPath completion:nil]; }; diff --git a/README.md b/README.md index 6c1e1a5..1576d36 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,8 @@ ## ObjectGraph + +![](https://travis-ci.org/vampirewalk/ObjectGraph-Xcode.svg?branch=master) +[![Twitter: @vampirewalk666](https://img.shields.io/badge/contact-%40vampirewalk-blue.svg)](https://twitter.com/vampirewalk666) + ObjectGraph can show oriented graph of dependencies between classes in your project. This plugin is based on [objc_dep](https://github.com/nst/objc_dep) and [Graphviz](http://www.graphviz.org/). @@ -6,6 +10,10 @@ This plugin is based on [objc_dep](https://github.com/nst/objc_dep) and [Graphvi ![Example](https://raw.githubusercontent.com/vampirewalk/ObjectGraph-Xcode/master/ObjectGraph.png) +- Black arrows: imports +- Red arrows: .pch imports +- Blue arrows: two ways imports + ## Usage The default path of source code parsing is project root path, you can set new path by clicking "Set Source Path Path...". For example, if you just want to parse your product class, not test class or external library class in Pods directory, you can set path to directory which contains your product class and execute "Draw Object Graph" again.