捆绑 mac 应用程序时出现问题

发布于 2024-10-28 22:08:11 字数 447 浏览 1 评论 0原文

我正在尝试制作一个 mac 应用程序包。它捆绑在一个 shell 文件中。结构是这样的:

App
    Contents
        Info.plist
            App.command
        MacOS
        Resources
            App.icns

但是,当我双击应用程序包时,它会显示以下提示:

要打开classroom.command,您需要安装Rosetta。您想现在安装吗? 看来

我的应用程序包不是基于英特尔的。但这没有意义。 Shell脚本跟什么平台没有关系吧?

我通过获取 .app 根文件夹的信息来验证它。我可以看到“种类”是“应用程序”。而在其他可启动的应用程序上,我看到“种类”是“应用程序(英特尔)”。我在 Info.plist 中错过了什么吗?

I'm trying to make a mac app bundle. It is bundled around a shell file. The structure is like this:

App
    Contents
        Info.plist
            App.command
        MacOS
        Resources
            App.icns

However, when I double click on the app bundle, it shows the following prompt:


To open classroom.command, you need to install Rosetta. Would you like to install it now?

It seems that my app bundle is not intel-based. But it doesn't make sense. Shell scripts have nothing to do with what platform it is right?

I verified it by getting info on the .app root folder. I can see that the "Kind" is "Application". Whereas on other launchable apps, I see that the "Kind" is "Application (Intel)". Is there something I missed from Info.plist?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

安稳善良 2024-11-04 22:08:11

看起来 MacOS 假定它是 Intel,除非明确告知它支持 ARM64。

我已经能够通过添加包含以下内容的文件 /Contents/Info.plist 来做到这一点:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>CFBundleExecutable</key>
    <string>run</string>
    <key>CFBundleIdentifier</key>
    <string>com.testing</string>
    <key>LSArchitecturePriority</key>
    <array>
        <string>arm64</string>
    </array>
    <key>LSRequiresNativeExecution</key>
    <true/>
</dict>
</plist>

此外,LSArchitecturePriority 值似乎已被缓存(或至少 Rosetta不会重新考虑运行该应用程序).​​..并且似乎将 CFBundleIdentifier 更改为其他任何内容就足以让它重试。


我不认为这是相关的,但我确实看到有人提到arm64程序需要签名,我一直在尝试使用以下方法来做到这一点(使用临时身份),但我认为没有必要(也许二进制文件需要):

codesign --timestamp --options=runtime -s "-" testing.app 

It looks like MacOS assumes it's Intel unless told explicitly that it supports ARM64.

I've been able to do that by adding the file /Contents/Info.plist with this contents:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>CFBundleExecutable</key>
    <string>run</string>
    <key>CFBundleIdentifier</key>
    <string>com.testing</string>
    <key>LSArchitecturePriority</key>
    <array>
        <string>arm64</string>
    </array>
    <key>LSRequiresNativeExecution</key>
    <true/>
</dict>
</plist>

Also, the LSArchitecturePriority value seems to be cached (or at least Rosetta would not re-consider running the app)... and it seems that changing the CFBundleIdentifier to anything else was enough to get it to try again.


I don't think this is relevant, but I did see someone mention that arm64 programs needed to be signed, I had been trying to do that with the following (using the ad-hoc identity), but I don't think it's necessary (maybe it's required for binaries):

codesign --timestamp --options=runtime -s "-" testing.app 
只是一片海 2024-11-04 22:08:11

Rosetta 是一款可以在 Intel Mac 上运行 PowerPC 代码的软件。根据您的处理器、操作系统,您可能需要安装它才能运行应用程序。

这是完整的解释

Rosetta is a piece of software through which PowerPC code can be run on an Intel Mac. Sow depending on your proccessor,OS you might need to instal it to run the application.

here is the full explanation

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文