From 5c088b0e31e60f0354fe048bb23b42071d435e6d Mon Sep 17 00:00:00 2001 From: Yeah Date: Mon, 27 Jul 2015 06:51:50 +0800 Subject: [PATCH 1/3] Add Xcode 6.4 DVTPlugInCompatibilityUUID --- XLocation/XLocation-Info.plist | 1 + 1 file changed, 1 insertion(+) diff --git a/XLocation/XLocation-Info.plist b/XLocation/XLocation-Info.plist index 7f633fd..4205bde 100644 --- a/XLocation/XLocation-Info.plist +++ b/XLocation/XLocation-Info.plist @@ -30,6 +30,7 @@ C4A681B0-4A26-480E-93EC-1218098B9AA0 A16FF353-8441-459E-A50C-B071F53F51B7 9F75337B-21B4-4ADC-B558-F9CADF7073A7 + 7FDF5C7A-131F-4ABB-9EDC-8C5F8F0B8A90 NSPrincipalClass LXLocation From 3845e1d09ed37559101fa5fd2608964bdb9b346f Mon Sep 17 00:00:00 2001 From: Yeah Date: Mon, 27 Jul 2015 06:56:32 +0800 Subject: [PATCH 2/3] Delete some Frameworks Search Paths for fixing the "directory not found for option '-F/..." Framework Error. --- XLocation.xcodeproj/project.pbxproj | 2 -- 1 file changed, 2 deletions(-) diff --git a/XLocation.xcodeproj/project.pbxproj b/XLocation.xcodeproj/project.pbxproj index 69befea..c1c1271 100644 --- a/XLocation.xcodeproj/project.pbxproj +++ b/XLocation.xcodeproj/project.pbxproj @@ -502,7 +502,6 @@ "$(inherited)", "$(SYSTEM_APPS_DIR)/Xcode.app/Contents/SharedFrameworks", "$(SYSTEM_APPS_DIR)/Xcode.app/Contents/Frameworks", - "$(USER_LIBRARY_DIR)/Developer/Xcode/DerivedData/XLocation-bvfsktypljbpaqcugmxxgbcspdud/Build/Products/Debug", ); GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "XLocation/XLocation-Prefix.pch"; @@ -528,7 +527,6 @@ "$(inherited)", "$(SYSTEM_APPS_DIR)/Xcode.app/Contents/SharedFrameworks", "$(SYSTEM_APPS_DIR)/Xcode.app/Contents/Frameworks", - "$(USER_LIBRARY_DIR)/Developer/Xcode/DerivedData/XLocation-bvfsktypljbpaqcugmxxgbcspdud/Build/Products/Debug", ); GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "XLocation/XLocation-Prefix.pch"; From 70f51d584dd65f6ca12caf6a0785be1e43384ba1 Mon Sep 17 00:00:00 2001 From: Yeah Date: Mon, 27 Jul 2015 07:10:40 +0800 Subject: [PATCH 3/3] Add Observer to get the NSMenuDidChangeItemNotification for the timing to add the menu item. Fixes #5 , Fixes #6 . --- XLocation/LXLocation.m | 48 ++++++++++++++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 11 deletions(-) diff --git a/XLocation/LXLocation.m b/XLocation/LXLocation.m index 7d3d97e..b7ac697 100644 --- a/XLocation/LXLocation.m +++ b/XLocation/LXLocation.m @@ -78,10 +78,45 @@ + (void)pluginDidLoad:(NSBundle *)plugin if ([currentApplicationName isEqual:@"Xcode"]) { dispatch_once(&onceToken, ^{ sharedPlugin = [[self alloc] initWithBundle:plugin]; + + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(menuDidChange) + name:NSMenuDidChangeItemNotification + object:nil]; }); } } ++ (void)menuDidChange +{ + [[NSNotificationCenter defaultCenter] removeObserver:self + name:NSMenuDidChangeItemNotification + object:nil]; + + [sharedPlugin createMenu]; + + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(menuDidChange) + name:NSMenuDidChangeItemNotification + object:nil]; +} + +- (void)createMenu +{ + if (!self.actionItem) + { + // Create new menu item in Debug + NSMenuItem *debugMenuItem = [[NSApp mainMenu] itemWithTitle:@"Debug"]; + if (debugMenuItem) { + [[debugMenuItem submenu] addItem:[NSMenuItem separatorItem]]; + self.actionItem = [[NSMenuItem alloc] initWithTitle:@"Add new Location" + action:@selector(addNewLocationMenu) + keyEquivalent:@""]; + [[debugMenuItem submenu] addItem:self.actionItem]; + } + } +} + - (id)initWithBundle:(NSBundle *)plugin { if (self = [super init]) { @@ -89,17 +124,8 @@ - (id)initWithBundle:(NSBundle *)plugin self.bundle = plugin; // Adds all observers [self addObservers]; - // Create new menu item in Debug - NSMenuItem *menuItem = [[NSApp mainMenu] itemWithTitle:@"Debug"]; - if (menuItem) { - [[menuItem submenu] addItem:[NSMenuItem separatorItem]]; - self.actionItem = [[NSMenuItem alloc] initWithTitle:@"Add new Location" - action:@selector(addNewLocationMenu) - keyEquivalent:@""]; - [[menuItem submenu] addItem:self.actionItem]; - // Init interface - [self loadWindow]; - } + // Init interface + [self loadWindow]; } return self; }