Skip to content

Commit 9bfc3ac

Browse files
pmattosmarcprux
authored andcommitted
Extends support for arm64e to macOS & visionOS platforms (#8837)
Extends arm64e support for macOS & visionOS apps, besides the existing iOS support. ### Motivation: SwiftPM currently only supports building arm64e packages for iOS. In Xcode 26 we added support to building packages for arm64e targeting macOS & visionOS platforms too. ### Modifications: Conditionally adds "arm64e" to the ARCHS build settings in the `PackagePIFBuilder` used to interface with Swift Build. ### Result: PIF builder nows had the capability of builds packages for arm64e. Note, for now, that this is currently disabled in SwiftPM. I validated this by building a simple macOS executable for arm64e: $ swift package init --type executable --name HelloWorld $ swift run swift-build --package-path HelloWorld --build-system swiftbuild ...and then I inspected the generated binary: $ lipo -archs HelloWorld/.build/arm64-apple-macosx/Products/Debug/HelloWorld arm64e
1 parent ff536d8 commit 9bfc3ac

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

Sources/SwiftBuildSupport/PIFBuilder.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -499,10 +499,10 @@ fileprivate final class PackagePIFBuilderDelegate: PackagePIFBuilder.BuildDelega
499499
[]
500500
}
501501

502-
var shouldiOSPackagesBuildForARM64e: Bool {
502+
func shouldPackagesBuildForARM64e(platform: PackageModel.Platform) -> Bool {
503503
false
504504
}
505-
505+
506506
var isPluginExecutionSandboxingDisabled: Bool {
507507
false
508508
}

Sources/SwiftBuildSupport/PackagePIFBuilder.swift

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,9 @@ public final class PackagePIFBuilder {
9494
/// Returns all *device family* IDs for all SDK variants.
9595
func deviceFamilyIDs() -> Set<Int>
9696

97-
/// Have packages referenced by this workspace build for arm64e when building for iOS devices.
98-
var shouldiOSPackagesBuildForARM64e: Bool { get }
97+
/// Have packages referenced by this workspace build for *arm64e*
98+
/// when building for iOS devices, macOS, and visionOS.
99+
func shouldPackagesBuildForARM64e(platform: PackageModel.Platform) -> Bool
99100

100101
/// Is the sandbox disabled for plug-in execution? It should be `false` by default.
101102
var isPluginExecutionSandboxingDisabled: Bool { get }
@@ -573,9 +574,18 @@ public final class PackagePIFBuilder {
573574
settings[.CODE_SIGNING_REQUIRED] = "NO"
574575
settings[.CODE_SIGN_IDENTITY] = ""
575576

576-
// If in a workspace that's set to build packages for arm64e, pass that along to Swift Build.
577-
if self.delegate.shouldiOSPackagesBuildForARM64e {
578-
settings.platformSpecificSettings[._iOSDevice]![.ARCHS] = ["arm64e"]
577+
// If in a workspace that's set to build packages for _arm64e_, pass that along to Swift Build.
578+
let arm64ePlatforms: [PackageModel.Platform] = [.iOS, .macOS, .visionOS]
579+
for arm64ePlatform in arm64ePlatforms {
580+
if self.delegate.shouldPackagesBuildForARM64e(platform: arm64ePlatform) {
581+
let pifPlatform: ProjectModel.BuildSettings.Platform = switch arm64ePlatform {
582+
case .iOS:
583+
._iOSDevice
584+
default:
585+
.init(from: arm64ePlatform)
586+
}
587+
settings.platformSpecificSettings[pifPlatform]![.ARCHS] = ["arm64e"]
588+
}
579589
}
580590

581591
// Add the build settings that are specific to debug builds, and set those as the "Debug" configuration.

0 commit comments

Comments
 (0)