无法在 mac 上打开简单的脚本应用程序

ins*_* me 0 mac osx-snow-leopard

Mac OS X 10.6

我创建了一个非常简单的应用程序,它只是一个 shell 脚本的包装器(这样我就可以在应用程序选择器中选择这个脚本,比如启动应用程序)。我尝试启动它,昨天它起作用了,但是今天我更改了可执行脚本的内容和名称(在终端中启动的 shell 脚本中使用完美的东西),它只会显示一个带有 Finder 图标的对话框,说

无法打开该应用程序,因为此类 Mac 不支持该应用程序。

我恢复了以前的脚本(内容/名称),但仍然出现错误!从头开始重新捆绑应用程序或完全更改捆绑标识符时相同......

如果我尝试使用在终端中打开它open My.app,我会得到

无法打开该应用程序,因为它的可执行格式不正确。

但是当我直接执行 时Contents/MacOS/Script,它始终有效(同时包含两个内容)。此外,它在 Finder 中显示正确的图标和元信息(所以我猜 Info.plist 被理解)。

该应用程序的文件树是:

Contents/
    Info.plist
    MacOS/
        Script    (executable bit set, works when launched directly)
    PkgInfo
    Resources/
        AppIcon.icns
Run Code Online (Sandbox Code Playgroud)

以下是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>Script</string>
    <key>CFBundleIconFile</key>
    <string>AppIcon</string>
    <key>CFBundleIdentifier</key>
    <string>asdf.ScriptApp</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleName</key>
    <string>My script</string>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>CFBundleShortVersionString</key>
    <string>1.0</string>
    <key>CFBundleSignature</key>
    <string>????</string>
    <key>CFBundleVersion</key>
    <string>1</string>
    <key>LSMinimumSystemVersion</key>
    <string>10.4</string>
</dict>
</plist>
Run Code Online (Sandbox Code Playgroud)

并且该PkgInfo文件仅包含APPL????. 我用一个简单的echo "ok"echo "ok" >/tmp/test(加上#!/bin/sh标题)测试了脚本。

所以我的问题是:

  • 应用程序是否有某种有效性缓存?基于什么 ?我该如何冲洗它?
  • 这个消息来自哪里?我试着用谷歌搜索,但我得到的只是一个关于 32/64 位 Java 的页面……

小智 6

这是非常死的,但我无法在谷歌上找到另一个已经被问到和回答的热门话题。我终于想通了(现在是 10.7):

shell 脚本文件必须以“#!”开头 这是奇怪的部分:它必须至少有 28 个字符长。

如果您放入一个 27 个字符的脚本并触摸该包,图标将变为一个带有一条线的应用程序。在脚本中添加一个字符并再次触摸它,BOOM,它起作用了。

很奇怪,不是吗?