@@ -21,7 +21,7 @@ public struct iOSVariant: Variant {
2121 let postSwitchScript : String ?
2222
2323 private let bundleNamingOption : BundleNamingOption
24-
24+
2525 public var title : String { name }
2626
2727 var configName : String {
@@ -38,8 +38,10 @@ public struct iOSVariant: Variant {
3838 }
3939
4040 init (
41- name: String , versionName: String , versionNumber: Int , appIcon: String ? , appName: String ? , storeDestination: String ? ,
42- custom: [ CustomProperty ] ? , idSuffix: String ? , bundleID: String ? , variantSigning: iOSSigning ? , globalSigning: iOSSigning ? ,
41+ name: String , versionName: String , versionNumber: Int , appIcon: String ? , appName: String ? ,
42+ storeDestination: String ? , idSuffix: String ? , bundleID: String ? ,
43+ globalCustomProperties: [ CustomProperty ] ? , variantCustomProperties: [ CustomProperty ] ? ,
44+ globalSigning: iOSSigning ? , variantSigning: iOSSigning ? ,
4345 globalPostSwitchScript: String ? , variantPostSwitchScript: String ? )
4446 throws {
4547 self . name = name
@@ -49,7 +51,7 @@ public struct iOSVariant: Variant {
4951 self . appName = appName
5052 self . storeDestination = try Self . parseDestination ( name: name, destination: storeDestination) ?? . appStore
5153 self . signing = try Self . parseSigning ( name: name, variantSigning: variantSigning, globalSigning: globalSigning)
52- self . custom = custom
54+ self . custom = Self . parseCustomProperties ( variantCustom : variantCustomProperties , globalCustom : globalCustomProperties )
5355 self . bundleNamingOption = try Self . parseBundleConfiguration ( name: name, idSuffix: idSuffix, bundleID: bundleID)
5456 self . postSwitchScript = Self . parsePostSwitchScript ( globalScript: globalPostSwitchScript,
5557 variantScript: variantPostSwitchScript)
@@ -78,14 +80,11 @@ public struct iOSVariant: Variant {
7880 if signing? . matchURL != nil , let exportMethod = signing? . exportMethod {
7981 customDictionary [ " V_MATCH_PROFILE " ] = " \( exportMethod. prefix) \( makeBundleID ( for: target) ) "
8082 }
81-
82- custom?
83- . filter { $0. destination == . project && !$0. isEnvironmentVariable }
84- . forEach { customDictionary [ $0. name] = $0. value }
85-
83+ ( custom? . projectConfigurationValues ?? [ ] ) . forEach { customDictionary [ $0. name] = $0. value }
84+
8685 return customDictionary. sorted ( by: { $0. key < $1. key} )
8786 }
88-
87+
8988 private static func parseDestination( name: String , destination: String ? ) throws -> Destination ? {
9089 guard let destinationString = destination else { return nil }
9190
@@ -116,7 +115,13 @@ public struct iOSVariant: Variant {
116115 return nil
117116 }
118117 }
119-
118+
119+ private static func parseCustomProperties( variantCustom: [ CustomProperty ] ? , globalCustom: [ CustomProperty ] ? ) -> [ CustomProperty ] {
120+ let variantCustomProperties = variantCustom ?? [ ]
121+ let globalMinusOverrideProperties = ( globalCustom ?? [ ] ) . filter { !variantCustomProperties. contains ( $0) }
122+ return globalMinusOverrideProperties + variantCustomProperties
123+ }
124+
120125 private static func parsePostSwitchScript( globalScript: String ? , variantScript: String ? ) -> String ? {
121126 if let globalScript = globalScript, let variantScript = variantScript {
122127 return " \( globalScript) && \( variantScript) "
@@ -207,19 +212,22 @@ extension UnnamediOSVariant {
207212}
208213
209214extension iOSVariant {
210- init ( from unnamediOSVariant: UnnamediOSVariant , name: String , globalSigning: iOSSigning ? , globalPostSwitchScript: String ? ) throws {
215+ init ( from unnamediOSVariant: UnnamediOSVariant , name: String , globalCustomProperties: [ CustomProperty ] ? ,
216+ globalSigning: iOSSigning ? , globalPostSwitchScript: String ? )
217+ throws {
211218 try self . init (
212219 name: name,
213220 versionName: unnamediOSVariant. versionName,
214221 versionNumber: unnamediOSVariant. versionNumber,
215222 appIcon: unnamediOSVariant. appIcon,
216223 appName: unnamediOSVariant. appName,
217224 storeDestination: unnamediOSVariant. storeDestination,
218- custom: unnamediOSVariant. custom,
219225 idSuffix: unnamediOSVariant. idSuffix,
220226 bundleID: unnamediOSVariant. bundleID,
221- variantSigning: unnamediOSVariant. signing,
227+ globalCustomProperties: globalCustomProperties,
228+ variantCustomProperties: unnamediOSVariant. custom,
222229 globalSigning: globalSigning,
230+ variantSigning: unnamediOSVariant. signing,
223231 globalPostSwitchScript: globalPostSwitchScript,
224232 variantPostSwitchScript: unnamediOSVariant. postSwitchScript)
225233 }
0 commit comments