From e4c2d62eb0021ba3544b2d9ca145581934dd1ab9 Mon Sep 17 00:00:00 2001 From: David Richardson Date: Wed, 20 Mar 2024 14:50:52 -0600 Subject: [PATCH] Clean up deprecation notices Reduce debugging noise by removing deprecation notices. --- .../XcodeCapp/XCCCappuccinoProject.m | 2 +- .../XCCCappuccinoProjectController.m | 54 +++++++++++++------ Tools/XcodeCapp/XcodeCapp/XCCMainController.m | 33 ++++++------ 3 files changed, 58 insertions(+), 31 deletions(-) diff --git a/Tools/XcodeCapp/XcodeCapp/XCCCappuccinoProject.m b/Tools/XcodeCapp/XcodeCapp/XCCCappuccinoProject.m index c28e34ce9..6aded2cff 100644 --- a/Tools/XcodeCapp/XcodeCapp/XCCCappuccinoProject.m +++ b/Tools/XcodeCapp/XcodeCapp/XCCCappuccinoProject.m @@ -364,7 +364,7 @@ NSString * const XCCCappuccinoProjectLastEventIDKey = @"XCCCappuccinoPro self->settings[XCCCappuccinoProcessObjj2ObjcSkeletonKey] = @(self.processObjj2ObjcSkeleton); self->settings[XCCCappuccinoProcessNib2CibKey] = @(self.processNib2Cib); self->settings[XCCCappuccinoProjectPreviousStatusKey] = [NSNumber numberWithInt:self.status]; - + if ([self.lastEventID boolValue]) self->settings[XCCCappuccinoProjectLastEventIDKey] = self.lastEventID; diff --git a/Tools/XcodeCapp/XcodeCapp/XCCCappuccinoProjectController.m b/Tools/XcodeCapp/XcodeCapp/XCCCappuccinoProjectController.m index 9d90bbc43..985650af4 100644 --- a/Tools/XcodeCapp/XcodeCapp/XCCCappuccinoProjectController.m +++ b/Tools/XcodeCapp/XcodeCapp/XCCCappuccinoProjectController.m @@ -93,15 +93,17 @@ void fsevents_callback(ConstFSEventStreamRef streamRef, void *userData, size_t n { [[NSApplication sharedApplication] activateIgnoringOtherApps:YES]; - NSRunAlertPanel( - self.cappuccinoProject.nickname, - @"XcodeCapp was unable to find all necessary executables in your environment:\n\n" - @"%@\n\n" - @"You certainly need to change the binary paths in the project settings.", - @"OK", - nil, - nil, - [self->taskLauncher.executables componentsJoinedByString:@", "]); + NSAlert *alert = [[NSAlert alloc] init]; + [alert setAlertStyle:NSAlertStyleCritical]; + NSString *title = self.cappuccinoProject.nickname; + [alert setMessageText:title]; + NSArray *informativeTextArray = @[ + @"XcodeCapp was unable to find all necessary executables in current environment:", + @"Please confirm the following executables are in current $PATH:\n", + [self->taskLauncher.executables componentsJoinedByString:@", "] + ]; + [alert setInformativeText:[informativeTextArray componentsJoinedByString:@"\n"]]; + [alert runModal]; [self _reinitializeProjectController]; } @@ -155,7 +157,12 @@ void fsevents_callback(ConstFSEventStreamRef streamRef, void *userData, size_t n if (![fm fileExistsAtPath:self.cappuccinoProject.projectPath isDirectory:nil]) { - NSRunAlertPanel(@"The project can’t be located.", @"It seems the project moved while XcodeCapp was not running.", @"Remove Project", nil, nil); + NSAlert *alert = [[NSAlert alloc] init]; + [alert setAlertStyle:NSAlertStyleCritical]; + [alert setMessageText:@"The project can’t be located"]; + NSString *informativeText = [NSString stringWithFormat:@"The project was either moved or deleted outside of the XcodeCapp environment.\nProject will be removed."]; + [alert setInformativeText:informativeText]; + [alert runModal]; [self.mainXcodeCappController unmanageCappuccinoProjectController:self]; return NO; @@ -1003,7 +1010,12 @@ void fsevents_callback(ConstFSEventStreamRef streamRef, void *userData, size_t n - (void)_handleProjectPathChange:(NSString *)path { - NSRunAlertPanel(self.cappuccinoProject.nickname, @"The project directory changed. This project will be removed", @"OK", nil, nil, nil); + NSAlert *alert = [[NSAlert alloc] init]; + [alert setAlertStyle:NSAlertStyleCritical]; + [alert setMessageText:@"The project directory changed"]; + NSString *informativeText = [NSString stringWithFormat:@"This project will be removed."]; + [alert setInformativeText:informativeText]; + [alert runModal]; [self.mainXcodeCappController unmanageCappuccinoProjectController:self]; } @@ -1206,15 +1218,27 @@ void fsevents_callback(ConstFSEventStreamRef streamRef, void *userData, size_t n if (!exists || !isDirectory || !isOpened) { - NSString *text; + NSString *projectErrorDescription; if (!isOpened) - text = @"The project exists, but failed to open."; + projectErrorDescription = @"The project exists, but failed to open."; else - text = [NSString stringWithFormat:@"%@ %@.", self.cappuccinoProject.XcodeProjectPath, !exists ? @"does not exist" : @"is not an Xcode project"]; + projectErrorDescription = [NSString stringWithFormat:@"%@ %@.", self.cappuccinoProject.XcodeProjectPath, !exists ? @"does not exist" : @"is not an Xcode project"]; [[NSApplication sharedApplication] activateIgnoringOtherApps:YES]; - NSInteger response = NSRunAlertPanel(@"The project could not be opened.", @"%@\n\nWould you like to regenerate the project?", @"Yes", @"No", nil, text); + + NSAlert *alert = [[NSAlert alloc] init]; + [alert setAlertStyle:NSAlertStyleCritical]; + [alert setMessageText:@"The project could not be opened"]; + NSArray *informativeTextArray = @[ + projectErrorDescription, + @"Should the project be regenerated?" + ]; + NSString *informativeText = [informativeTextArray componentsJoinedByString:@"\n"]; + [alert setInformativeText:informativeText]; + [alert addButtonWithTitle:@"Yes"]; + [alert addButtonWithTitle:@"No"]; + NSInteger response = [alert runModal]; if (response == NSAlertFirstButtonReturn) [self resetProject:self]; diff --git a/Tools/XcodeCapp/XcodeCapp/XCCMainController.m b/Tools/XcodeCapp/XcodeCapp/XCCMainController.m index 905b74b9d..b7a80a447 100644 --- a/Tools/XcodeCapp/XcodeCapp/XCCMainController.m +++ b/Tools/XcodeCapp/XcodeCapp/XCCMainController.m @@ -180,13 +180,12 @@ if (missingProjects.count) { - NSRunAlertPanel(@"Missing Projects", - @"Some managed projects could not be found and have been removed:\n\n" - @"%@\n\n", - @"OK", - nil, - nil, - [missingProjects componentsJoinedByString:@", "]); + NSString *informativeText = [NSString stringWithFormat:@"Some managed projects could not be found and have been removed:\n\n%@", [missingProjects componentsJoinedByString:@", "]]; + NSAlert *alert = [[NSAlert alloc] init]; + [alert setAlertStyle:NSAlertStyleCritical]; + [alert setMessageText:@"Missing Projects"]; + [alert setInformativeText:informativeText]; + [alert runModal]; } [self _saveManagedProjectsToUserDefaults]; @@ -238,7 +237,11 @@ { if ([[self.cappuccinoProjectControllers filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"cappuccinoProject.projectPath == %@", path]] count]) { - NSRunAlertPanel(@"This project is already managed.", @"Please remove the other project or use the reset button.", @"OK", nil, nil, nil); + NSAlert *alert = [[NSAlert alloc] init]; + [alert setAlertStyle:NSAlertStyleCritical]; + [alert setMessageText:@"This project is already managed."]; + [alert setInformativeText:@"Please remove the other project or use the reset button."]; + [alert runModal]; return; } @@ -306,16 +309,16 @@ - (IBAction)addProject:(id)aSender { - NSOpenPanel *openPanel = [NSOpenPanel openPanel]; - openPanel.title = @"Add a new Cappuccino Project to XcodeCapp"; - openPanel.canCreateDirectories = YES; - openPanel.canChooseDirectories = YES; - openPanel.canChooseFiles = NO; + NSOpenPanel *openPanel = [NSOpenPanel openPanel]; + openPanel.title = @"Add a new Cappuccino Project to XcodeCapp"; + openPanel.canCreateDirectories = YES; + openPanel.canChooseDirectories = YES; + openPanel.canChooseFiles = NO; - if ([openPanel runModal] != NSFileHandlingPanelOKButton) + if ([openPanel runModal] != NSModalResponseOK) return; - NSString *projectPath = [[openPanel.URLs[0] path] stringByStandardizingPath]; + NSString *projectPath = [[openPanel.URLs[0] path] stringByStandardizingPath]; [self manageCappuccinoProjectControllerForPath:projectPath]; }