macos 应用程序无法打开,因为它的可执行文件丢失
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2182040/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
The application cannot be opened because its executable is missing
提问by Daniel Grace
I have an application that I have been developing for some time now. Recently launching the application via a double click presents a dialog that says "You can't open the application RepoWatch because it may be damaged or incomplete."
我有一个应用程序,我已经开发了一段时间了。最近通过双击启动应用程序会出现一个对话框,显示“您无法打开应用程序 RepoWatch,因为它可能已损坏或不完整。”
Launching the application via open ./RepoWatch.app gives me "The application cannot be opened because its executable is missing."
通过 open ./RepoWatch.app 启动应用程序给我“应用程序无法打开,因为它的可执行文件丢失。”
I usually launch the application via ./RepoWatch.app/Contents/MacOS/RepoWatch simply out of habit (which DOES work), so I am unsure how long this has been happening, or what change happened immediately before hand. The most likely change is that I put cp Info.plist ./RepoWatch.app/Contents/
into my make file in order to version Info.plist without versioning everything in the .app bundle.
我通常只是出于习惯而通过 ./RepoWatch.app/Contents/MacOS/RepoWatch 启动应用程序(这确实有效),所以我不确定这已经发生了多久,或者之前发生了什么变化。最可能的变化是我放入cp Info.plist ./RepoWatch.app/Contents/
我的 make 文件中,以便版本 Info.plist 而不对 .app 包中的所有内容进行版本控制。
I have looked at Info.plist many times and cannot find anything wrong with it. The file opens up with Property List Editor without any errors. Saving from Property List Editor does not make the file "work" (if it is to blame in the first place).
我已经多次查看 Info.plist 并没有发现它有什么问题。该文件使用属性列表编辑器打开,没有任何错误。从属性列表编辑器保存不会使文件“工作”(如果首先应该归咎于它)。
The permissions as far as I can tell also look sane:
据我所知,权限看起来也很正常:
$ 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
I am at a loss as to what to try next.
我不知道接下来要尝试什么。
And here are the contents of Info.plist (Even though nothing has really changed in quite a while):
以下是 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>
回答by Stuart Berg
Building on the answer that @smokris posted:
基于@smokris 发布的答案:
The problem seems to be with your app's registration in the Launch Services database. There is no need to rebuild the entire database. To force-update the entry for your app (specifically), use lsregister
with the -f
option:
问题似乎与您的应用程序在 Launch Services 数据库中的注册有关。无需重建整个数据库。要强制更新您的应用程序的条目(特别是),请使用lsregister
以下-f
选项:
/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -f MyApp.app
I was having the same problem you describe, and this worked for me. Thanks, @smokris!
我遇到了你描述的同样问题,这对我有用。谢谢,@smokris!
回答by smokris
Rebuilding the Launch Services database solves this problem for me.
重建 Launch Services 数据库为我解决了这个问题。
Try executing the following command in Terminal:
尝试在终端中执行以下命令:
/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user
回答by Chris Johnsen
The problem is likely due to an invalid CFBundleExecutable
propertyvalue in the Info.plist
file you are copying into the application.
问题很可能是由于您要复制到应用程序的文件中的CFBundleExecutable
属性值无效Info.plist
。
In Xcode projects the default value for this property is a special variable (placeholder) value (${EXECUTABLE_NAME}
) that is expanded (replaced) when the build system builds the application. Are you sure you need to copy this file manually? Maybe you can add a script build phase that makes whatever changes you need afterit has been expanded and copied into place by the normal build process.
在 Xcode 项目中,此属性的默认值是一个特殊的变量(占位符)值 ( ${EXECUTABLE_NAME}
),它在构建系统构建应用程序时被扩展(替换)。您确定需要手动复制此文件吗?也许您可以添加一个脚本构建阶段,在它被正常构建过程扩展并复制到位后,进行任何您需要的更改。
While you are at it, you should check for other placeholder values in the file. It is likely that you will need to fill in CFBundleName
(others may also be necessary, depending on your application type).
在此期间,您应该检查文件中的其他占位符值。您可能需要填写CFBundleName
(其他也可能是必要的,具体取决于您的申请类型)。
回答by Chris Johnsen
OK, some (more) shots in the dark.
好的,在黑暗中拍摄一些(更多)镜头。
- The docs for LSMinimumSystemVersionsay that the value is supposed to be a string with the form n.n.n. You might try adding a “.0” to the end of your value.
- When you use
./RepoWatch.app/Contents/MacOS/RepoWatch
to run it manually, are you using some sort of completion or filename generation, or are you typing it all in (especially the filename of the executable)?- Maybe the executable filename has some odd invisible/combining/look-alike character in it that does not match the value in
Info.plist
. Tryls -w /path/to/RepoWatch.app/Contents/MacOS/ | xxd
to look at the bytes for anything non-ASCII.
- Maybe the executable filename has some odd invisible/combining/look-alike character in it that does not match the value in
- Does
plutil -lint /path/to/Info.plist
give you an “OK”? - The
@
after the permissions in thels -l
output indicates some xattrs. These could be harmless, but have you looked at which ones are there withls -l@
?- If one of the xattrs looks suspect (or even if not) you could
(cd /path/to/RepoWatch.app/Contents/ && mv Info.plist Info.plist.save && cat Info.plist.save > Info.plist)
to get a copy without the xattrs and test with it. - If using the non-xattr'd file still causes problems, you might try systematically modifying and deleting keys (after making a backup copy, like the
.save
above) to see if you can cause a different error message that might help indicate the problem.
- If one of the xattrs looks suspect (or even if not) you could
- LSMinimumSystemVersion的文档说该值应该是形式为nnn的字符串。您可以尝试在值的末尾添加“.0”。
- 当您使用
./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@
?- 如果其中一个 xattrs 看起来可疑(或者即使没有),您可以
(cd /path/to/RepoWatch.app/Contents/ && mv Info.plist Info.plist.save && cat Info.plist.save > Info.plist)
获取一份没有 xattrs 的副本并使用它进行测试。 - 如果使用非 xattr 文件仍然导致问题,您可以尝试系统地修改和删除密钥(在制作备份副本后,
.save
如上所示)以查看是否可以导致不同的错误消息,这可能有助于指出问题。
- 如果其中一个 xattrs 看起来可疑(或者即使没有),您可以
回答by Alex Clarke
Project Menu > Set Active Executable
项目菜单 > 设置活动可执行文件