Skip to content

Commit 0bba287

Browse files
Improve handling of conditional build settings
- Keep conditional build settings grouped together by base setting - Only generate build setting info comment once per base setting - Resolves #91
1 parent b3c731e commit 0bba287

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

BuildSettingExtractor/BuildSettingExtractor.m

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,16 +346,21 @@ + (NSString *)stringRepresentationOfBuildSettings:(NSDictionary *)buildSettings
346346
}
347347

348348
BOOL firstKey = YES;
349+
NSString *previousKey = nil;
349350
for (NSString *key in sortedKeys) {
350351
id value = buildSettings[key];
352+
353+
// If same base setting name as previous key, this is a conditional build setting.
354+
// Don't put newlines between them and don't repeat the build setting info comment.
355+
BOOL sameBaseSettingName = [previousKey tps_baseBuildSettingNameIsEqualTo:key]; // nil previousKey returns nil aka NO
351356

352-
if (!firstKey){
357+
if (!firstKey && !sameBaseSettingName){
353358
for (NSInteger i = 0; i < linesBetweenSettings; i++) {
354359
[string appendString:@"\n"];
355360
}
356361
}
357362

358-
if (includeBuildSettingInfoComments) {
363+
if (includeBuildSettingInfoComments && !sameBaseSettingName) {
359364
NSString *comment = [buildSettingCommentGenerator commentForBuildSettingWithName:key];
360365
[string appendString:comment];
361366
}
@@ -376,6 +381,7 @@ + (NSString *)stringRepresentationOfBuildSettings:(NSDictionary *)buildSettings
376381
[NSException raise:@"Should not get here!" format:@"Unexpected class: %@ in %s", [value class], __PRETTY_FUNCTION__];
377382
}
378383

384+
previousKey = key;
379385
firstKey = NO;
380386
}
381387

0 commit comments

Comments
 (0)