From 0f62624e902bb5b23d03ae085ee4f417b2f93e46 Mon Sep 17 00:00:00 2001 From: JP Simard Date: Mon, 13 Jun 2022 10:38:17 -0400 Subject: [PATCH 1/2] Speed up SettingsBuilder It's unnecessary to build up a whole grouped dictionary only to check if all platforms are identical and then immediately discard the dictionary. Instead we can check if all targets match the first platform, which avoids creating a new dictionary but also allows bailing early as soon as a non-matching platform is found. Generating a large project (36MB json spec) on an M1 Max machine leads to a ~6% total speedup: 28.48s vs 30.07s. --- Sources/XcodeGenKit/SettingsBuilder.swift | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/Sources/XcodeGenKit/SettingsBuilder.swift b/Sources/XcodeGenKit/SettingsBuilder.swift index 4ac1853c3..36a252db9 100644 --- a/Sources/XcodeGenKit/SettingsBuilder.swift +++ b/Sources/XcodeGenKit/SettingsBuilder.swift @@ -11,12 +11,10 @@ extension Project { var buildSettings: BuildSettings = [:] // set project SDKROOT is a single platform - if targets.count > 0 { - let platforms = Dictionary(grouping: targets) { $0.platform } - if platforms.count == 1 { - let platform = platforms.first!.key - buildSettings["SDKROOT"] = platform.sdkRoot - } + if let firstPlatform = targets.first?.platform, + targets.allSatisfy({ $0.platform == firstPlatform }) + { + buildSettings["SDKROOT"] = firstPlatform.sdkRoot } if let type = config.type, options.settingPresets.applyProject { @@ -31,7 +29,7 @@ extension Project { } } - // Prevent setting presets from overrwriting settings in project xcconfig files + // Prevent setting presets from overwriting settings in project xcconfig files if let configPath = configFiles[config.name] { buildSettings = removeConfigFileSettings(from: buildSettings, configPath: configPath) } From cadf8eebe38f0ab16bc878a4b8d842a6b2082889 Mon Sep 17 00:00:00 2001 From: JP Simard Date: Tue, 14 Jun 2022 10:22:08 -0400 Subject: [PATCH 2/2] Add changelog entry --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index aa5408714..b8200acb7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## Next Version +### Changed + +- Speed up generating build settings for large projects #1221 @jpsim + ## 2.29.0 Some support for Xcode Test Plans has been added. For now test plans are not generated by XcodeGen and must be created in Xcode and checked in, and then referenced by path. If the test targets are added, removed or renamed, the test plans may need to be updated in Xcode