Skip to content

Commit 4c3d558

Browse files
authored
Fix supportedDestinations presets being injected when settingPresets is none (#1599)
Gate the supportedDestinations YAML preset block inside the applyTarget check so that settingPresets: none (and project) suppresses Catalyst-related settings (SUPPORTS_MACCATALYST, SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD, SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD) that were previously always injected. Fixes #1598
1 parent a0afcef commit 4c3d558

2 files changed

Lines changed: 31 additions & 16 deletions

File tree

Sources/XcodeGenKit/SettingsBuilder.swift

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -65,26 +65,26 @@ extension Project {
6565
// this fix is necessary because the platform preset overrides the original value
6666
buildSettings["SDKROOT"] = .string(Platform.auto.rawValue)
6767
}
68-
}
69-
70-
if !specSupportedDestinations.isEmpty {
71-
var supportedPlatforms: [String] = []
72-
var targetedDeviceFamily: [String] = []
7368

74-
for supportedDestination in specSupportedDestinations {
75-
let supportedPlatformBuildSettings = SettingsPresetFile.supportedDestination(supportedDestination).getBuildSettings()
76-
buildSettings += supportedPlatformBuildSettings
69+
if !specSupportedDestinations.isEmpty {
70+
var supportedPlatforms: [String] = []
71+
var targetedDeviceFamily: [String] = []
7772

78-
if let value = supportedPlatformBuildSettings?["SUPPORTED_PLATFORMS"]?.stringValue {
79-
supportedPlatforms += value.components(separatedBy: " ")
80-
}
81-
if let value = supportedPlatformBuildSettings?["TARGETED_DEVICE_FAMILY"]?.stringValue {
82-
targetedDeviceFamily += value.components(separatedBy: ",")
73+
for supportedDestination in specSupportedDestinations {
74+
let supportedPlatformBuildSettings = SettingsPresetFile.supportedDestination(supportedDestination).getBuildSettings()
75+
buildSettings += supportedPlatformBuildSettings
76+
77+
if let value = supportedPlatformBuildSettings?["SUPPORTED_PLATFORMS"]?.stringValue {
78+
supportedPlatforms += value.components(separatedBy: " ")
79+
}
80+
if let value = supportedPlatformBuildSettings?["TARGETED_DEVICE_FAMILY"]?.stringValue {
81+
targetedDeviceFamily += value.components(separatedBy: ",")
82+
}
8383
}
84+
85+
buildSettings["SUPPORTED_PLATFORMS"] = .string(supportedPlatforms.joined(separator: " "))
86+
buildSettings["TARGETED_DEVICE_FAMILY"] = .string(targetedDeviceFamily.joined(separator: ","))
8487
}
85-
86-
buildSettings["SUPPORTED_PLATFORMS"] = .string(supportedPlatforms.joined(separator: " "))
87-
buildSettings["TARGETED_DEVICE_FAMILY"] = .string(targetedDeviceFamily.joined(separator: ","))
8888
}
8989

9090
// apply custom platform version

Tests/XcodeGenKitTests/ProjectGeneratorTests.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,21 @@ class ProjectGeneratorTests: XCTestCase {
516516
try expect(targetConfig1.buildSettings["SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD"]?.boolValue) == false
517517
}
518518

519+
$0.it("supportedDestinations respects settingPresets none") {
520+
let target = Target(name: "Target", type: .application, platform: .auto, supportedDestinations: [.iOS, .macOS])
521+
let options = SpecOptions(settingPresets: .none)
522+
let project = Project(name: "", targets: [target], options: options)
523+
524+
let pbxProject = try project.generatePbxProj()
525+
let targetConfig = try unwrap(pbxProject.nativeTargets.first?.buildConfigurationList?.buildConfigurations.first)
526+
527+
try expect(targetConfig.buildSettings["SUPPORTS_MACCATALYST"]).beNil()
528+
try expect(targetConfig.buildSettings["SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD"]).beNil()
529+
try expect(targetConfig.buildSettings["SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD"]).beNil()
530+
try expect(targetConfig.buildSettings["SUPPORTED_PLATFORMS"]).beNil()
531+
try expect(targetConfig.buildSettings["TARGETED_DEVICE_FAMILY"]).beNil()
532+
}
533+
519534
$0.it("generates dependencies") {
520535
let pbxProject = try project.generatePbxProj()
521536

0 commit comments

Comments
 (0)