// // XCodeHelper.m // XCode Perforce // // Created by Rob Crawford on 8/26/16. // Copyright © 2016 Rob Crawford. All rights reserved. // #import "XCodeHelper.h" #import "XCode.h" @implementation XCodeHelper +(NSString *)pathToCurrentDocument { NSString *result; XCodeApplication *applicaiton = [SBApplication applicationWithBundleIdentifier:@"com.apple.dt.Xcode"]; XCodeDocument *firstDocument=nil; XCodeWindow *firstWindow = applicaiton.windows[0]; NSString *name = firstWindow.name; for (XCodeDocument *aDoc in applicaiton.documents) { NSString *lastComponent = [aDoc.file.path lastPathComponent]; if ([name isEqualToString:lastComponent]) { firstDocument = aDoc; break; } } if (firstDocument) { result = firstDocument.file.path; if ([result.pathExtension isEqualToString:@"xcodeproj"]) { result = [result stringByAppendingPathComponent:@"project.pbxproj"]; } } return result; } +(NSURL *)currentProjectURL { XCodeApplication *applicaiton = [SBApplication applicationWithBundleIdentifier:@"com.apple.dt.Xcode"]; XCodeDocument *firstDocument = applicaiton.documents[0]; return firstDocument.file; } @end