我有一个我已经开发了一段时间的应用程序。最近通过双击启动应用程序会出现一个对话框,显示“您无法打开应用程序RepoWatch,因为它可能已损坏或不完整。”
通过打开./RepoWatch.app启动应用程序,“我无法打开应用程序,因为缺少可执行文件。”
我通常是通过./RepoWatch.app/Contents/MacOS/RepoWatch启动应用程序,只是出于习惯(工作正常),所以我不确定这种情况发生了多长时间,或者事先发生了什么变化。最可能的变化是我将cp Info.plist ./RepoWatch.app/Contents/
放入我的make文件中以版本Info.plist而不对.app包中的所有内容进行版本控制。
我多次查看过Info.plist,但发现它没有任何问题。该文件使用Property List Editor打开,没有任何错误。从属性列表编辑器中保存不会使文件“正常工作”(如果首先要归咎于它)。
据我所知,权限看起来也很健全:
$ ls -l
./RepoWatch.app/Contents/Info.plist
-rw-rw-r--@ 1 dgrace staff 789 Feb 1 23:20 ./RepoWatch.app/Contents/Info.plist
$ ls -l
/Applications/Adium.app/Contents/Info.plist
-rw-rw-r-- 1 dgrace staff 5750 Aug 21 15:41 /Applications/Adium.app/Contents/Info.plist
我不知道下一步该尝试什么。
以下是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>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>RepoWatch</string>
<key>CFBundleIdentifier</key>
<string>com.doomstick.RepoWatch</string>
<key>CFBundleName</key>
<string>RepoWatch</string>
<key>CFBundleShortVersionString</key>
<string>1.0.0</string>
<key>LSMinimumSystemVersion</key>
<string>10.6</string>
<key>CFBundleVersion</key>
<string>Beta26</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
</dict>
</plist>
答案 0 :(得分:12)
基于@smokris发布的答案:
问题似乎与您的应用在Launch Services数据库中的注册有关。无需重建整个数据库。要强制更新应用的条目(具体而言),请使用lsregister
选项-f
:
/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -f MyApp.app
我遇到了你描述的同样的问题,这对我有用。谢谢,@ smokris!
答案 1 :(得分:11)
重建Launch Services数据库为我解决了这个问题。
尝试在终端中执行以下命令:
/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user
答案 2 :(得分:6)
问题可能是由于您要复制到应用程序中的Info.plist
文件中的CFBundleExecutable
property值无效。
在Xcode项目中,此属性的默认值是特殊变量(占位符)值(${EXECUTABLE_NAME}
),当构建系统构建应用程序时,该值将被展开(替换)。您确定需要手动复制此文件吗?也许你可以添加一个脚本构建阶段,在你通过正常的构建过程扩展并复制到后,你需要进行任何改变。
当你在它时,你应该检查文件中的其他占位符值。您可能需要填写CFBundleName
(其他可能也是必要的,具体取决于您的申请类型)。
答案 3 :(得分:2)
好的,在黑暗中拍摄一些(更多)。
./RepoWatch.app/Contents/MacOS/RepoWatch
手动运行时,是使用某种完成或文件名生成,还是全部输入(特别是可执行文件的文件名)?
Info.plist
中的值不匹配。尝试ls -w /path/to/RepoWatch.app/Contents/MacOS/ | xxd
查看非ASCII字节的字节。plutil -lint /path/to/Info.plist
会给你一个“OK”吗?@
输出中的权限后ls -l
表示某些xattrs。这些可能是无害的,但你看过哪些ls -l@
?
(cd /path/to/RepoWatch.app/Contents/ && mv Info.plist Info.plist.save && cat Info.plist.save > Info.plist)
获得没有xattrs的副本并用它进行测试。.save
),看看是否可能导致不同的错误消息这可能有助于表明问题。答案 4 :(得分:1)
项目菜单&gt;设置Active Executable