Q1: LSArchitecturePriority

未设置 LSArchitecturePriority, 会使 shell-script application 陷入 Rosetta translation 处境。

查询文档和日志确认后,可知,如果无可执行二进制文件,默认行为是运行在 Rosetta translation 下。

If an app doesn’t contain an executable binary, the system may run it under Rosetta translation as a precautionary measure to prevent potential runtime issues. For example, the system runs script-only apps under Rosetta translation.

[CoreServicesUIAgent (LaunchServices)] [com.apple.launchservices] [prefs-storage]
GET prefs[Architectures for arm64][app.xxx.yyy] = x86_64

[CoreServicesUIAgent (LaunchServices)] [com.apple.launchservices] [open]
LAUNCH: Launch failure with -10669/ <FSNode 0x6000015271c0> { isDir = y, path = 'xxx.app' }

此值位于 ~/Library/Preferences/com.apple.LaunchServices/com.apple.LaunchServices.plist.

此值有强缓存,须从配置文件删除此项,重启生效。

/usr/libexec/PlistBuddy -c "Delete :\"Architectures for arm64\":app.xxx.yyy" ~/Library/Preferences/com.apple.LaunchServices/com.apple.LaunchServices.plist

设置 Info.plist LSArchitecturePriority

<key>LSArchitecturePriority</key>
<array>
    <string>arm64</string>
</array>

Q2: LSRequiresNativeExecution

shell-script application 需要 LSRequiresNativeExecution 吗?

需要。

在设定 LSArchitecturePriority 后,shell-script 已可以运行,但之后还要看情况去阻止 Rosetta translation.

Q3: 确认 Launch Service database 状态

/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -dump

移动 xxx.app 位置,可令状态刷新。

参考


Related Posts


Published

Category

macos

Tags

Contact