@@ -137,6 +137,7 @@ extension ProjectModel {
137
137
case SWIFT_WARNINGS_AS_ERRORS_GROUPS
138
138
}
139
139
140
+ @available ( * , deprecated, message: " Use subscripts to set platform-specific SingleValueSetting/MultipleValueSettings instead " )
140
141
public enum Declaration : String , Hashable , CaseIterable , Sendable {
141
142
case ARCHS
142
143
case GCC_PREPROCESSOR_DEFINITIONS
@@ -186,8 +187,6 @@ extension ProjectModel {
186
187
}
187
188
}
188
189
189
- public var platformSpecificSettings = [ Platform: [ Declaration: [ String] ] ] ( )
190
-
191
190
public init ( ) {
192
191
var settings : [ Declaration : [ String ] ] = [ : ]
193
192
for declaration in Declaration . allCases {
@@ -201,6 +200,13 @@ extension ProjectModel {
201
200
202
201
private( set) var singleValueSettings : OrderedDictionary < String , String > = [ : ]
203
202
private( set) var multipleValueSettings : OrderedDictionary < String , [ String ] > = [ : ]
203
+ private( set) var singleValuePlatformSpecificSettings = [ Platform : OrderedDictionary < String , String > ] ( )
204
+ private( set) var multipleValuePlatformSpecificSettings = [ Platform : OrderedDictionary < String , [ String ] > ] ( )
205
+
206
+ // Kept for API compatibility
207
+ @available ( * , deprecated, message: " Use subscripts to set platform-specific settings instead " )
208
+ public var platformSpecificSettings = [ Platform: [ Declaration: [ String] ] ] ( )
209
+
204
210
205
211
public subscript( _ setting: SingleValueSetting ) -> String ? {
206
212
get { singleValueSettings [ setting. rawValue] }
@@ -221,6 +227,16 @@ extension ProjectModel {
221
227
get { multipleValueSettings [ setting] }
222
228
set { multipleValueSettings [ setting] = newValue }
223
229
}
230
+
231
+ public subscript( _ setting: SingleValueSetting , platform: Platform ) -> String ? {
232
+ get { singleValuePlatformSpecificSettings [ platform] ? [ setting. rawValue] }
233
+ set { singleValuePlatformSpecificSettings [ platform, default: . init( ) ] [ setting. rawValue] = newValue }
234
+ }
235
+
236
+ public subscript( _ setting: MultipleValueSetting , platform: Platform ) -> [ String ] ? {
237
+ get { multipleValuePlatformSpecificSettings [ platform] ? [ setting. rawValue] }
238
+ set { multipleValuePlatformSpecificSettings [ platform, default: . init( ) ] [ setting. rawValue] = newValue }
239
+ }
224
240
}
225
241
}
226
242
@@ -325,6 +341,23 @@ extension ProjectModel.BuildSettings: Codable {
325
341
self . platformSpecificSettings [ platform, default: [ : ] ] [ declaration] = value
326
342
}
327
343
}
344
+ let declarationValues = Set ( Declaration . allCases. map ( \. rawValue) )
345
+ for key in SingleValueSetting . allCases {
346
+ if declarationValues. contains ( key. rawValue) {
347
+ continue
348
+ }
349
+ if let value = try container. decodeIfPresent ( String . self, forKey: StringKey ( " \( key. rawValue) [ \( condition) ] " ) ) {
350
+ self [ key, platform] = value
351
+ }
352
+ }
353
+ for key in MultipleValueSetting . allCases {
354
+ if declarationValues. contains ( key. rawValue) {
355
+ continue
356
+ }
357
+ if let value = try container. decodeIfPresent ( [ String ] . self, forKey: StringKey ( " \( key. rawValue) [ \( condition) ] " ) ) {
358
+ self [ key, platform] = value
359
+ }
360
+ }
328
361
}
329
362
}
330
363
}
@@ -351,5 +384,21 @@ extension ProjectModel.BuildSettings: Codable {
351
384
}
352
385
}
353
386
}
387
+
388
+ for (platform, table) in singleValuePlatformSpecificSettings {
389
+ for condition in platform. asConditionStrings {
390
+ for (key, value) in table {
391
+ try container. encode ( value, forKey: StringKey ( " \( key) [ \( condition) ] " ) )
392
+ }
393
+ }
394
+ }
395
+
396
+ for (platform, table) in multipleValuePlatformSpecificSettings {
397
+ for condition in platform. asConditionStrings {
398
+ for (key, value) in table {
399
+ try container. encode ( value, forKey: StringKey ( " \( key) [ \( condition) ] " ) )
400
+ }
401
+ }
402
+ }
354
403
}
355
404
}
0 commit comments