From 9fc0b2558b3637aa097f66f49cba6f2f46e63410 Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Fri, 13 Jun 2025 09:11:22 -0700 Subject: [PATCH] Enforce VALID_ARCHS for simulator platforms This allows projects to build more smoothly across platforms when architectures like arm64e are unconditionally appended to ARCHS. Simulators have never supported arm64e in any capacity. rdar://123839235 --- Sources/SWBApplePlatform/Plugin.swift | 2 +- Sources/SWBApplePlatform/Specs/iOSSimulator.xcspec | 8 -------- Sources/SWBApplePlatform/Specs/tvOSSimulator.xcspec | 8 -------- .../SWBApplePlatform/Specs/watchOSSimulator.xcspec | 8 -------- Sources/SWBApplePlatform/Specs/xrOSSimulator.xcspec | 8 -------- .../Extensions/SettingsBuilderExtension.swift | 2 +- Sources/SWBCore/Settings/Settings.swift | 12 ++++-------- 7 files changed, 6 insertions(+), 42 deletions(-) diff --git a/Sources/SWBApplePlatform/Plugin.swift b/Sources/SWBApplePlatform/Plugin.swift index 2288a849..5bdd8d3b 100644 --- a/Sources/SWBApplePlatform/Plugin.swift +++ b/Sources/SWBApplePlatform/Plugin.swift @@ -239,7 +239,7 @@ struct AppleSettingsBuilderExtension: SettingsBuilderExtension { func addPlatformSDKSettings(_ platform: SWBCore.Platform?, _ sdk: SDK, _ sdkVariant: SDKVariant?) -> [String : String] { [:] } func xcconfigOverrideData(fromParameters: BuildParameters) -> ByteString { ByteString() } func getTargetTestingSwiftPluginFlags(_ scope: MacroEvaluationScope, toolchainRegistry: ToolchainRegistry, sdkRegistry: SDKRegistry, activeRunDestination: RunDestinationInfo?, project: SWBCore.Project?) -> [String] { [] } - func shouldSkipPopulatingValidArchs(platform: SWBCore.Platform) -> Bool { false } + func shouldSkipPopulatingValidArchs(platform: SWBCore.Platform, sdk: SDK?) -> Bool { false } func shouldDisableXOJITPreviews(platformName: String, sdk: SDK?) -> Bool { false } func overridingBuildSettings(_: MacroEvaluationScope, platform: SWBCore.Platform?, productType: ProductTypeSpec) -> [String : String] { [:] } } diff --git a/Sources/SWBApplePlatform/Specs/iOSSimulator.xcspec b/Sources/SWBApplePlatform/Specs/iOSSimulator.xcspec index e0dba20f..0da7e552 100644 --- a/Sources/SWBApplePlatform/Specs/iOSSimulator.xcspec +++ b/Sources/SWBApplePlatform/Specs/iOSSimulator.xcspec @@ -40,14 +40,6 @@ SortNumber = 107; }, - { - _Domain = iphonesimulator; - Type = Architecture; - Identifier = arm64e; - PerArchBuildSettingName = "arm64e"; - SortNumber = 108; - }, - // DEPRECATED { diff --git a/Sources/SWBApplePlatform/Specs/tvOSSimulator.xcspec b/Sources/SWBApplePlatform/Specs/tvOSSimulator.xcspec index 157d5c8d..d881885a 100644 --- a/Sources/SWBApplePlatform/Specs/tvOSSimulator.xcspec +++ b/Sources/SWBApplePlatform/Specs/tvOSSimulator.xcspec @@ -49,14 +49,6 @@ SortNumber = 107; }, - { - _Domain = appletvsimulator; - Type = Architecture; - Identifier = arm64e; - PerArchBuildSettingName = "arm64e"; - SortNumber = 108; - }, - // DEPRECATED { diff --git a/Sources/SWBApplePlatform/Specs/watchOSSimulator.xcspec b/Sources/SWBApplePlatform/Specs/watchOSSimulator.xcspec index 4deabd40..06993c54 100644 --- a/Sources/SWBApplePlatform/Specs/watchOSSimulator.xcspec +++ b/Sources/SWBApplePlatform/Specs/watchOSSimulator.xcspec @@ -48,14 +48,6 @@ SortNumber = 107; }, - { - _Domain = watchsimulator; - Type = Architecture; - Identifier = arm64e; - PerArchBuildSettingName = "arm64e"; - SortNumber = 108; - }, - // DEPRECATED { diff --git a/Sources/SWBApplePlatform/Specs/xrOSSimulator.xcspec b/Sources/SWBApplePlatform/Specs/xrOSSimulator.xcspec index 546a901a..49bb9043 100644 --- a/Sources/SWBApplePlatform/Specs/xrOSSimulator.xcspec +++ b/Sources/SWBApplePlatform/Specs/xrOSSimulator.xcspec @@ -40,14 +40,6 @@ SortNumber = 107; }, - { - _Domain = xrsimulator; - Type = Architecture; - Identifier = arm64e; - PerArchBuildSettingName = "arm64e"; - SortNumber = 108; - }, - // DEPRECATED { diff --git a/Sources/SWBCore/Extensions/SettingsBuilderExtension.swift b/Sources/SWBCore/Extensions/SettingsBuilderExtension.swift index 3cb6dcde..0f1ee377 100644 --- a/Sources/SWBCore/Extensions/SettingsBuilderExtension.swift +++ b/Sources/SWBCore/Extensions/SettingsBuilderExtension.swift @@ -48,7 +48,7 @@ public protocol SettingsBuilderExtension { // Provides a list of flags to configure testing plugins func getTargetTestingSwiftPluginFlags(_ scope: MacroEvaluationScope, toolchainRegistry: ToolchainRegistry, sdkRegistry: SDKRegistry, activeRunDestination: RunDestinationInfo?, project: Project?) -> [String] // Override valid architectures enforcement for a platform - func shouldSkipPopulatingValidArchs(platform: Platform) -> Bool + func shouldSkipPopulatingValidArchs(platform: Platform, sdk: SDK?) -> Bool func shouldDisableXOJITPreviews(platformName: String, sdk: SDK?) -> Bool diff --git a/Sources/SWBCore/Settings/Settings.swift b/Sources/SWBCore/Settings/Settings.swift index 3bd6636e..356b04f8 100644 --- a/Sources/SWBCore/Settings/Settings.swift +++ b/Sources/SWBCore/Settings/Settings.swift @@ -2626,23 +2626,19 @@ private class SettingsBuilder { core.pluginManager.extensions(of: SettingsBuilderExtensionPoint.self) } - func shouldPopulateValidArchs(platform: Platform) -> Bool { + func shouldPopulateValidArchs(platform: Platform, sdk: SDK?) -> Bool { // For now, we only do this for some platforms to avoid behavior changes. // Later, we should extend this to more SDKs via switch platform.name { case "macosx", "iphoneos", - "iphonesimulator", "appletvos", - "appletvsimulator", "watchos", - "watchsimulator", - "xros", - "xrsimulator": + "xros": return false default: for settingsExtension in settingsExtensions() { - if settingsExtension.shouldSkipPopulatingValidArchs(platform: platform) { + if settingsExtension.shouldSkipPopulatingValidArchs(platform: platform, sdk: sdk) { return false } } @@ -2651,7 +2647,7 @@ private class SettingsBuilder { } // VALID_ARCHS should be based on the SDK's SupportedTargets dictionary. - if let archs = sdkVariant?.archs, !archs.isEmpty, let platform, shouldPopulateValidArchs(platform: platform) { + if let archs = sdkVariant?.archs, !archs.isEmpty, let platform, shouldPopulateValidArchs(platform: platform, sdk: sdk) { table.push(BuiltinMacros.VALID_ARCHS, literal: archs) }