简体   繁体   English

SMJobBless导致kSMErrorDomainFramework错误5 - 指定路径上的工具无效

[英]SMJobBless causes kSMErrorDomainFramework error 5 - The tool at the specified path is not valid

Running SMJobBless: 运行SMJobBless:

(PrefPane project xcode version 4 Build 4A304a) (PrefPane项目xcode版本4 Build 4A304a)

SMJobBless(kSMDomainSystemLaunchd, @"com.coderama.coderamaHelper", authRef, &err);

Causes this error: 导致此错误:

System Preferences[22312:903] Bless Error: Error Domain=kSMErrorDomainFramework Code=5 UserInfo=0x2005790e0 "The operation couldn’t be completed. (kSMErrorDomainFramework error 5 - The tool at the specified path is not valid.)"

Below are my plists. 以下是我的帖子。

Can anyone decipher the error message so I can attempt to troubleshoot this? 任何人都可以破译错误消息,以便我可以尝试解决此问题吗? I have gone over all of my plists to make sure the names match-up. 我已经查看了所有的帖子,以确保名称匹配。

coderama-info.plist: coderama-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>CFBundleDevelopmentRegion</key>
    <string>English</string>
    <key>CFBundleExecutable</key>
    <string>${EXECUTABLE_NAME}</string>
    <key>CFBundleIconFile</key>
    <string></string>
    <key>CFBundleIdentifier</key>
    <string>com.coderama.${PRODUCT_NAME:rfc1034identifier}</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleName</key>
    <string>${PRODUCT_NAME}</string>
    <key>CFBundlePackageType</key>
    <string>BNDL</string>
    <key>CFBundleShortVersionString</key>
    <string>1.0</string>
    <key>CFBundleSignature</key>
    <string>????</string>
    <key>CFBundleVersion</key>
    <string>1.0</string>
    <key>NSHumanReadableCopyright</key>
    <string>Copyright © 2012 coderama. All rights reserved.</string>
    <key>NSMainNibFile</key>
    <string>coderama</string>
    <key>NSPrefPaneIconFile</key>
    <string>show_wireframe_zoom_24.gif</string>
    <key>NSPrefPaneIconLabel</key>
    <string>coderama</string>
    <key>NSPrincipalClass</key>
    <string>coderama</string>
    <key>SMPrivilegedExecutables</key>
    <dict>
        <key>com.coderama.coderamaHelper</key>
        <string>identifier com.coderama.coderamaHelper and certificate leaf[subject.CN] = &quot;Joe Developer&quot;</string>
    </dict>
</dict>
</plist>

coderamaHelper-info.plist: coderamaHelper-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>CFBundleIdentifier</key>
    <string>com.coderama.coderamaHelper</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleName</key>
    <string>coderamaHelper</string>
    <key>CFBundleVersion</key>
    <string>1.0</string>
    <key>SMAuthorizedClients</key>
    <array>
        <string>identifier com.coderama.coderama and certificate leaf[subject.CN] = &quot;Joe Developer&quot;</string>
    </array>
</dict>
</plist>

coderamaHelper-Launchd.plist looks like this: coderamaHelper-Launchd.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>Label</key>
    <string>com.coderama.coderamaHelper</string>
    <key>MachServices</key>
    <dict>
        <key>com.coderama.coderamaHelper.mach</key>
        <true/>
    </dict>
</dict>
</plist>

I went to this error too, at first check again the steps declared in the readme.txt of the SMJobless project: 我也去了这个错误,首先再次检查SMJobless项目的readme.txt中声明的步骤:

  1. In the application go to: Target/Build Phases /Copy Files and make 在应用程序中转到:目标/构建阶段/复制文件并制作
    sure that the parameters are correctly assigned: Destination = wrapper, 确保正确分配参数:Destination = wrapper,
    subpath = Contents/Library/LaunchServices, and finally load the subpath = Contents / Library / LaunchServices,最后加载
    daemon or service into the project. 守护进程或服务进入项目。
  2. In the application go to the file info.plist and check for the following key :"Tools owned after installation" and set it up to= 在应用程序中,转到文件info.plist并检查以下密钥:“安装后拥有的工具”并将其设置为=
    identifier com.acme.MyService and certificate leaf[subject.CN] = 标识符com.acme.MyService和证书leaf [subject.CN] =
    "MyCertificate" . “MyCertificate”。 You must replace MyService and MyCertificate by 您必须替换MyService和MyCertificate
    your own ones. 你自己的。
  3. In the helper tool or daemon go to info.plist file. 在帮助工具或守护进程中转到info.plist文件。 Here you have to add some key/value pairs, the first one is: "Clients allowed to add and remove tool" which must be set to "identifier 在这里你必须添加一些键/值对,第一个是:“允许添加和删除工具的客户端”,必须设置为“标识符”
    com.acme.MyApp and certificate leaf[subject.CN] = "MyCertificate" com.acme.MyApp和证书leaf [subject.CN] =“MyCertificate”
    ,remember replace MyApp and MyCertificate by your own ones. ,请记住用自己的替换MyApp和MyCertificate。
  4. Finally make sure that THE DAEMON is embedded in the executable itself before Build it, this is accomplished by this way: In the helper tool or daemon go to target/Build Settings/Linking/Other Linker Flags and add the following: 最后确保在构建它之前将DAEMON嵌入到可执行文件中,这是通过以下方式实现的:在帮助工具或守护进程中转到目标/构建设置/链接/其他链接器标志并添加以下内容:

    -sectcreate -sectcreate
    __TEXT __文本
    __info_plist __info_plist
    MyDaemon/info.plist MyDaemon / info.plist中
    -sectcreate -sectcreate
    __TEXT __文本
    _launchd_plist _launchd_plist
    MyDaemon/myDaemon-launchd.plist MyDaemon / myDaemon-launchd.plist

Make sure to replace MyDaemon for the correct values of your own development. 确保将MyDaemon替换为您自己开发的正确值。 Be careful with the names of your info and launchd files. 请注意info和launchd文件的名称。

IMPORTANT TIP : THE NAME OF THE DAEMON OR SERVICE MUST CORRESPOND TO THE SAME NAME WRITTEN IN THE INFO.PLIST AND LAUNCHD.PLIST FILES OTHERWISE IT WILL GENERATE THE ERROR kSMErrorDomainFramework error 5 - The tool at the specified path is not valid. 重要提示 :DAEMON或服务的名称必须与INFO.PLIST和LAUNCHD.PLIST文件中的相同名称相对应,否则将产生错误kSMErrorDomainFramework错误5 - 指定路径上的工具无效。

一位Apple开发人员回复我说SMJobBless仅适用于Applications。

This error occurs when the helper tool is not bundled in the correct location, and so SMJobBless() can't find the tool for installation. 如果辅助工具未捆绑在正确的位置,则会发生此错误,因此SMJobBless()无法找到要安装的工具。 In the Build Phases section of your main application target, you have to add a Copy Files build phase. 在主应用程序目标的Build Phases部分中,您必须添加Copy Files构建阶段。 Add your helper tool, set the destination to Wrapper and the subpath to Contents/Library/LaunchServices , and SMJobBless() will be able to find your helper tool. 添加帮助工具,将目标设置为Wrapper ,将子路径设置为Contents/Library/LaunchServicesSMJobBless()将能够找到您的帮助工具。

Check the documentation for SMJobBless for the list of requirements. 查看SMJobBless的文档以获取要求列表。 My guess is that you missed step 1 (code-signing both the tool and your app) or step 5 (copying the tool to the correct place in your app wrapper). 我的猜测是你错过了第1步(对工具和应用程序进行代码签名)或第5步(将工具复制到应用包装器中的正确位置)。

Also, [NSString @"com.coderama.coderamaHelper"] makes no sense. 另外, [NSString @"com.coderama.coderamaHelper"]毫无意义。 Just write @"com.coderama.coderamaHelper" . 只需写@"com.coderama.coderamaHelper"

If all else fails, look at what the sample code does and follow its example. 如果所有其他方法都失败了,请查看示例代码的作用并遵循其示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM