What makes an OS X app not open with the error “LSOpenURLsWithRole() failed with error -10810”?

ぐ巨炮叔叔 提交于 2019-12-10 17:35:59

问题


I am working on what should be a very simple application bundle for OS X. My OS is version 10.7.5. The app in this case is a shell script.

Kerkerkruip.app/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>Kerkerkruip</string>
    <key>CFBundleIconFile</key>
    <string>Kicon.icns</string>
    <key>CFBundleIdentifier</key>
    <string>org.kerkerkruip.Kerkerkruip</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleName</key>
    <string>Kerkerkruip</string>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <!--<key>CFBundleSignature</key>
    <string>????</string>-->
    <key>CFBundleVersion</key>
    <string>9.0.1</string>
    <key>LSMinimumSystemVersion</key>
    <string>10.4</string>
    <key>NSHumanReadableCopyright</key>
    <string>© 2011-2015 by the Kerkerkruip team</string>
    <!--<key>NSMainNibFile</key>
    <string>MainMenu</string>-->
    <!--<key>NSPrincipalClass</key>
    <string>NSApplication</string>-->
</dict>
</plist>

Kerkerkruip.app/Contents/MacOS/Kerkerkruip:

#!/usr/bin/env bash
echo "This is a blank script." 1>&2
exit 1

When I try to open the app I get the following error message:

$ open Kerkerkruip.app/
The application cannot be opened because it has an incorrect executable format.

The script is set +x. I have seen this question on SuperUser but nothing there helped - my script is over 27 characters.

Edit: After following the instructions in this other question to rebuild the Launch Services database for my app, trying to open it now produces:

LSOpenURLsWithRole() failed with error -10810 for the file /Users/dannii/Documents/kerkerkruip/packages/osx/Kerkerkruip.app.

回答1:


I did some testing, and was able to reproduce your second error.

LSOpenURLsWithRole() failed with error -10810 for the file /PATH/TO/Kerkerkruip.app.

After experimentation, it looks like the issue is caused by your shell script exiting with the error code of 1. If you exit with the success code of 0, the error does not occur.

Example:

#!/usr/bin/env bash
echo "This is a blank script." 1>&2
exit 0


来源:https://stackoverflow.com/questions/28105587/what-makes-an-os-x-app-not-open-with-the-error-lsopenurlswithrole-failed-with

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!