@@ -118,10 +118,26 @@ let main = command(
118118 baseResults [ idx] . settings = distinctArray ( common + baseResults[ idx] . settings)
119119 // Write Upper Layer Configs (e.g. App-Debug.xcconfig, AppTests-Debug.xcconfig)
120120 for r in filtered {
121- r . settings = r . settings - common
122- try write ( to : r. path , lines : formatter . format ( result : r ) ) // not including any other xcconfigs for targets'
121+ let idx = targetResults . index ( of : r ) !
122+ targetResults [ idx ] . settings = r. settings - common
123123 }
124124 }
125+ // Trim Duplicates in target configs (e.g. App-Debug.xcconfig and App-Release.xcconfig)
126+ for target in pbxproj. rootObject. targets {
127+ let filtered = targetResults
128+ . filter { $0. path. components. last!. characters. starts ( with: " \( target. name) - " . characters) }
129+ let common : [ String ] = commonElements ( filtered. map { $0. settings } )
130+ let targetConfigPath = Path ( " \( dirPath. string) / \( target. name) .xcconfig " )
131+ let r = ResultObject ( path: targetConfigPath, settings: common)
132+ try write ( to: r. path, lines: formatter. format ( result: r) )
133+ for r in filtered {
134+ let idx = targetResults. index ( of: r) !
135+ targetResults [ idx] . settings = r. settings - common
136+ targetResults [ idx] . includes += [ targetConfigPath. lastComponent]
137+ try write ( to: r. path, lines: formatter. format ( result: targetResults [ idx] ) )
138+ }
139+ }
140+
125141 // Trim Duplicates in configurationName configs (e.g. Debug.xcconfig and Release.xcconfig)
126142 let common = commonElements ( baseResults. map { $0. settings } )
127143 // Write Configuration Base Configs (e.g. Debug.xcconfig, Release.xcconfig)
0 commit comments