Skip to content

Commit 0c7fccf

Browse files
authored
Build fat packages when shouldPackagesBuildForARM64e is set (#8969)
### Motivation: I extended arm64e support for macOS & visionOS apps in my previous PR #8837. When enabled, that patch *only* produced the arm64e slice but... The App Store will now accept arm64e for macOS, iOS, and visionOS — arm64e is optional and off by default. But when you turn on arm64e support for packages (ie, using `shouldPackagesBuildForARM64e` PIF builder delegate method) we expect *both* slices in the binary now. ### Modifications: Changes the PIF builder to update the ARCHS settings without overriding it completely, ensuring we get all required slices (ie, a so called fat binary). ### Result: PIF builder nows has the capability of building packages for arm64 and arm64e. (Note, for now, that this is currently disabled in SwiftPM.) I validated this by building a simple macOS executable for arm64e (and force enabling it in SwifPM): $ swift package init --type executable --name HelloWorld $ swift run swift-build --package-path HelloWorld --build-system swiftbuild --configuration release ...and then I inspected the generated binary: $ lipo -archs HelloWorld/.build/arm64-apple-macosx/Products/Release/HelloWorld x86_64 arm64 arm64e Debug builds. With ONLY_ACTIVE_ARCH = "YES" in debug builds, even though you specify multiple architectures in ARCHS, it will still only build for the active architecture during development. This is set to "NO" for release builds.
1 parent ea18f28 commit 0c7fccf

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Sources/SwiftBuildSupport/PackagePIFBuilder.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ public final class PackagePIFBuilder {
590590
default:
591591
.init(from: arm64ePlatform)
592592
}
593-
settings.platformSpecificSettings[pifPlatform]![.ARCHS] = ["arm64e"]
593+
settings.platformSpecificSettings[pifPlatform]![.ARCHS, default: []].append(contentsOf: ["arm64e"])
594594
}
595595
}
596596

0 commit comments

Comments
 (0)