Declare native execution in macOS .app bundle Info.plist#27591
Declare native execution in macOS .app bundle Info.plist#27591KiloNiner wants to merge 3 commits into
Conversation
Add LSRequiresNativeExecution to the macOS launcher app Info.plist so Apple Silicon Launch Services does not offer Rosetta when opening /Applications/PowerShell.app. The shipped pwsh binary is arm64-native in the osx-arm64 package; the Rosetta prompt is purely a bundle-metadata artifact (script-based CFBundleExecutable, unsigned bundle, no arch hint in the plist). The key is a no-op on Intel Macs (no Rosetta translates Intel binaries on Intel hardware), so it is safe to add unconditionally to the shared template used for both osx-arm64.pkg and osx-x64.pkg builds. Fixes PowerShell#18548
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds an Info.plist setting during packaging to require native execution on macOS.
Changes:
- Adds
LSRequiresNativeExecutionset totruein the packaged app’s Info.plist template.
Address review feedback: only emit the LSRequiresNativeExecution key in
the launcher Info.plist for osx-arm64 builds, not for osx-x64.
The previous version added the key unconditionally to the shared
template. That is safe on Intel Macs (the key is a no-op on hardware
where Rosetta does not translate Intel binaries) and on Apple Silicon
running the arm64 build (the goal), but it would prevent the .app
launcher from working under Rosetta if an Apple Silicon user installs
the osx-x64 package -- an unsupported but previously-working
configuration.
Make the substitution conditional via a new HostArchitecture parameter
on New-MacOSLauncher, threaded through from New-UnixPackage where
HostArchitecture is already in scope ("arm64" or "x86_64" for osxpkg
builds). The plist template gains a {3} placeholder that receives
either the LSRequiresNativeExecution block (arm64) or empty (x86_64).
|
@microsoft-github-policy-service agree |
| # When "arm64", emits LSRequiresNativeExecution in the app's Info.plist so | ||
| # Apple Silicon Launch Services does not offer Rosetta when launching | ||
| # /Applications/PowerShell.app. Leave empty / non-arm64 to preserve the | ||
| # ability to launch x86_64 builds under Rosetta on Apple Silicon. | ||
| [string]$HostArchitecture |
There was a problem hiding this comment.
This comment is important, but hard to understand. Can it be clarified?
There was a problem hiding this comment.
Certainly. The change carries through the CPU type to the packaging script, allowing us to set the instruction to not attempt to use Rosetta, by requiring native execution rather than emulation, when launching the arm64 version of the software on arm64 hardware.
If someone, for a reason I'm not sure of, still wants to launch the x86 version on arm64, then we take care to not sabotage emulation through Rosetta on that version.
The entire fix is required as launch services can't derive the image type from the launcher script and does the conservative thing, which is to treat it as requiring emulation.
I have pushed a new commit with more inline comments around the changes.
Explain that the root cause requiring the key is Launch Services being unable to infer CPU architecture from a shell script launcher, causing it to default to offering Rosetta translation. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
PR Summary
Adds
LSRequiresNativeExecution = trueto the macOS launcher appInfo.plisttemplate so opening/Applications/PowerShell.appon Apple Silicon does not trigger a Rosetta prompt.PR Context
On Apple Silicon, double-clicking
/Applications/PowerShell.appfrom theosx-arm64.pkgproduces a "To open PowerShell, you need to install Rosetta" prompt, even though the underlyingpwshbinary is arm64-native and runningpwshfrom a terminal works without any prompt. This has been reported repeatedly (#18548, #27587, and historical #17130 whose original dylib root cause no longer applies —libmi.dylib/libpsrpclient.dylibwere removed and all remaining dylibs in the arm64 package are arm64 or universal).The surviving root cause is in the static bundle metadata generated from
tools/packaging/packaging.strings.psd1:CFBundleExecutableis a shell script (PowerShell.sh), not a Mach-O binary, so Launch Services cannot infer architecture from the executable.Info.plisthas noLSRequiresNativeExecutionkey.With nothing telling Launch Services the bundle is native, Apple Silicon defaults to offering Rosetta. Ironically the actual
pwshthat ends up running is arm64 either way — Rosetta would only be wrapping the launcher script.Setting
LSRequiresNativeExecution = truetells Launch Services explicitly that the bundle must run natively, which suppresses the Rosetta prompt on Apple Silicon. The key is a no-op on Intel Macs (no Rosetta translates Intel binaries on Intel hardware), so it is safe to add to the shared template used for bothosx-arm64.pkgandosx-x64.pkgbuilds without conditional logic.Verified on a fresh install of
powershell-7.6.2-osx-arm64.pkg:The existing macOS package validation tests in
test/packaging/macos/package-validation.tests.ps1verify that the plist exists and the bundle structure is correct, but do not assert on plist contents, so no test changes are required.Fixes #18548
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright header