@@ -117,18 +117,28 @@ - (BOOL)extractBuildSettingsFromProject:(NSURL *)projectWrapperURL toDestination
117117 NSDictionary *projectSettings = [self buildSettingStringsByConfigurationForBuildConfigurationListID: buildConfigurationListID];
118118
119119 self.buildSettingsByTarget [validatedProjectConfigName] = projectSettings;
120+
121+ // Begin check that the project file has some settings
122+ BOOL projectFileHasSettings = projectSettings.containsBuildSettings ;
120123
121124 // Add project targets
122125 for (NSDictionary *target in targets) {
123126 NSString *targetName = target[@" name" ];
124127 buildConfigurationListID = target[@" buildConfigurationList" ];
125128 NSDictionary *targetSettings = [self buildSettingStringsByConfigurationForBuildConfigurationListID: buildConfigurationListID];
129+ if (!projectFileHasSettings) { projectFileHasSettings = targetSettings.containsBuildSettings ; }
126130
127131 self.buildSettingsByTarget [targetName] = targetSettings;
128132
129133 }
130134
131- [self writeConfigFilesToDestinationFolder: folderURL];
135+ if (projectFileHasSettings) {
136+ [self writeConfigFilesToDestinationFolder: folderURL];
137+ } else {
138+ [self presentErrorForNoSettingsFoundInProject: [projectWrapperURL lastPathComponent ]];
139+ success = NO ;
140+ }
141+
132142 }
133143 }
134144 return success;
@@ -160,6 +170,20 @@ - (void)presentErrorForNameConflictWithName:(NSString *)conflictedName validated
160170
161171}
162172
173+ // Notify the user we did not find any settings in the project.
174+ - (void )presentErrorForNoSettingsFoundInProject : (NSString *)projectName {
175+ NSString *errorDescription = [NSString stringWithFormat: @" No settings found." ];
176+ NSString *errorRecoverySuggestion = [NSString stringWithFormat: @" No settings were found in the project \' %@ \' .\n\n The project may already be using .xcconfig files for its build settings.\n\n No xcconfig files will be written. " , projectName];
177+ NSDictionary *errorUserInfo = @{NSLocalizedDescriptionKey :errorDescription, NSLocalizedRecoverySuggestionErrorKey : errorRecoverySuggestion};
178+
179+ NSError *error = [NSError errorWithDomain: [[NSBundle mainBundle ] bundleIdentifier ] code: NoSettingsFoundInProjectFile userInfo: errorUserInfo];
180+
181+ dispatch_async (dispatch_get_main_queue (), ^{
182+ [NSApp presentError: error];
183+ });
184+
185+ }
186+
163187/* Writes an xcconfig file for each target / configuration combination to the specified directory.
164188 */
165189- (void )writeConfigFilesToDestinationFolder : (NSURL *)destinationURL {
0 commit comments