Skip to content

Commit 11e6bde

Browse files
Report extraction success. Don't open in Finder on failure.
1 parent 2dcec3a commit 11e6bde

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

BuildSettingExtractor/AppDelegate.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ - (IBAction)handleDroppedFile:(DragFileView *)sender {
6868
buildSettingExtractor.nameSeparator = [defaults stringForKey:TPSOutputFileNameSeparator];
6969
buildSettingExtractor.includeBuildSettingInfoComments = [[NSUserDefaults standardUserDefaults] boolForKey:TPSIncludeBuildSettingInfoComments];
7070

71-
[buildSettingExtractor extractBuildSettingsFromProject:fileURL toDestinationFolder:destinationURL];
71+
BOOL success = [buildSettingExtractor extractBuildSettingsFromProject:fileURL toDestinationFolder:destinationURL];
7272

7373
BOOL openInFinder = [[NSUserDefaults standardUserDefaults] boolForKey:TPSOpenDirectoryInFinder];
74-
if (openInFinder) {
74+
if (success && openInFinder) {
7575
[[NSWorkspace sharedWorkspace] openURL:destinationURL];
7676
}
7777
});

BuildSettingExtractor/BuildSettingExtractor.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
// Should each build setting be commented with title and description, if available.
4545
@property (assign) BOOL includeBuildSettingInfoComments;
4646

47-
- (void)extractBuildSettingsFromProject:(NSURL *)projectWrapperURL toDestinationFolder:(NSURL *)folderURL;
47+
// Returns whether extraction of build settings was successful
48+
- (BOOL)extractBuildSettingsFromProject:(NSURL *)projectWrapperURL toDestinationFolder:(NSURL *)folderURL;
4849

4950
@end

BuildSettingExtractor/BuildSettingExtractor.m

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,18 @@ - (NSArray *)objectArrayForDictionary:(NSDictionary *)dict key:(NSString *)key {
5656
return objectArray;
5757
}
5858

59-
- (void)extractBuildSettingsFromProject:(NSURL *)projectWrapperURL toDestinationFolder:(NSURL *)folderURL {
59+
- (BOOL)extractBuildSettingsFromProject:(NSURL *)projectWrapperURL toDestinationFolder:(NSURL *)folderURL {
6060

6161
[self.buildSettingsByTarget removeAllObjects];
6262

6363
NSError *error = nil;
64+
BOOL success = YES;
6465

6566
NSURL *projectFileURL = [projectWrapperURL URLByAppendingPathComponent:@"project.pbxproj"];
6667

6768
NSData *fileData = [NSData dataWithContentsOfURL:projectFileURL options:0 error:&error];
6869
if (!fileData) {
70+
success = NO;
6971
dispatch_async(dispatch_get_main_queue(), ^{
7072
[NSApp presentError:error];
7173
});
@@ -74,6 +76,7 @@ - (void)extractBuildSettingsFromProject:(NSURL *)projectWrapperURL toDestination
7476
NSDictionary *projectPlist = [NSPropertyListSerialization propertyListWithData:fileData options:NSPropertyListImmutable format:NULL error:&error];
7577

7678
if (!projectPlist) {
79+
success = NO;
7780
dispatch_async(dispatch_get_main_queue(), ^{
7881
[NSApp presentError:error];
7982
});
@@ -88,10 +91,11 @@ - (void)extractBuildSettingsFromProject:(NSURL *)projectWrapperURL toDestination
8891
if (![compatibilityVersion isEqualToString:XcodeCompatibilityVersionString]) {
8992
NSDictionary *userInfo = @{NSLocalizedDescriptionKey:[NSString stringWithFormat:@"Unable to extract build settings from project ‘%@’.", [[projectWrapperURL lastPathComponent] stringByDeletingPathExtension]], NSLocalizedRecoverySuggestionErrorKey: [NSString stringWithFormat:@"Project file format version ‘%@’ is not supported.", compatibilityVersion]};
9093
NSError *error = [NSError errorWithDomain:[[NSBundle mainBundle] bundleIdentifier] code:UnsupportedXcodeVersion userInfo:userInfo];
94+
success = NO;
9195
dispatch_async(dispatch_get_main_queue(), ^{
9296
[NSApp presentError:error];
9397
});
94-
return;
98+
return success;
9599
}
96100

97101
// Get project settings
@@ -116,6 +120,7 @@ - (void)extractBuildSettingsFromProject:(NSURL *)projectWrapperURL toDestination
116120
[self writeConfigFilesToDestinationFolder:folderURL];
117121
}
118122
}
123+
return success;
119124
}
120125

121126

0 commit comments

Comments
 (0)