@@ -103,21 +103,32 @@ - (void)writeConfigFilesToDestinationFolder:(NSURL *)destinationURL {
103
103
[self .buildSettingsByTarget enumerateKeysAndObjectsUsingBlock: ^(id targetName, id obj, BOOL *stop) {
104
104
[obj enumerateKeysAndObjectsUsingBlock: ^(id configName, id settings, BOOL *stop) {
105
105
106
+ NSString *filename = [self configFilenameWithTargetName: targetName configName: configName];
107
+
108
+ NSString *configFileString = @" " ;
109
+
110
+ // Add header comment
111
+ NSString *headerComment = [self headerCommentForFilename: filename];
112
+ if (headerComment) {
113
+ configFileString = [configFileString stringByAppendingString: headerComment];
114
+ }
115
+
106
116
// If the config name is not the shared config, we need to import the shared config
107
117
if (![configName isEqualToString: self .sharedConfigName]) {
108
118
NSString *configFilename = [self configFilenameWithTargetName: targetName configName: self .sharedConfigName];
109
119
NSString *includeDirective = [NSString stringWithFormat: @" #include \" %@ \"\n\n " , configFilename];
110
- settings = [includeDirective stringByAppendingString: settings ];
120
+ configFileString = [configFileString stringByAppendingString: includeDirective ];
111
121
}
112
122
123
+ configFileString = [configFileString stringByAppendingString: settings];
124
+
113
125
// Trim whitespace and newlines
114
- settings = [settings stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet ]];
126
+ configFileString = [configFileString stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet ]];
115
127
116
- NSString *filename = [self configFilenameWithTargetName: targetName configName: configName];
117
128
118
129
NSURL *fileURL = [destinationURL URLByAppendingPathComponent: filename];
119
130
120
- BOOL success = [settings writeToURL: fileURL atomically: YES encoding: NSUTF8StringEncoding error: nil ];
131
+ BOOL success = [configFileString writeToURL: fileURL atomically: YES encoding: NSUTF8StringEncoding error: nil ];
121
132
if (!success) NSLog (@" No success with %@ " , fileURL);
122
133
}];
123
134
}];
@@ -128,6 +139,23 @@ - (NSString *)configFilenameWithTargetName:(NSString *)targetName configName:(NS
128
139
return [NSString stringWithFormat: @" %@ -%@ .xcconfig" , targetName, configName];
129
140
}
130
141
142
+ // Given the filename generate the header comment
143
+ - (NSString *)headerCommentForFilename : (NSString *)filename {
144
+ NSString *headerComment = @" " ;
145
+
146
+ NSString *dateString = [NSDateFormatter localizedStringFromDate: [NSDate date ] dateStyle: NSDateFormatterShortStyle timeStyle: NSDateFormatterNoStyle];
147
+
148
+ headerComment = [headerComment stringByAppendingString: @" //\n " ];
149
+ headerComment = [headerComment stringByAppendingFormat: @" // %@ \n " , filename];
150
+ headerComment = [headerComment stringByAppendingString: @" //\n " ];
151
+ headerComment = [headerComment stringByAppendingFormat: @" // Generated by BuildSettingExtractor on %@ \n " , dateString];
152
+ headerComment = [headerComment stringByAppendingString: @" // https://github.com/dempseyatgithub/BuildSettingExtractor\n " ];
153
+ headerComment = [headerComment stringByAppendingString: @" //\n " ];
154
+ headerComment = [headerComment stringByAppendingString: @" \n " ];
155
+
156
+ return headerComment;
157
+ }
158
+
131
159
132
160
/* Given a build setting dictionary, returns a string representation of the build settings, suitable for an xcconfig file. */
133
161
- (NSString *)stringRepresentationOfBuildSettings : (NSDictionary *)buildSettings {
0 commit comments