SMJobBless throws error kSMErrorDomainFramework 5 - Tool on the specified path is invalid

Running SMJobBless:

(PrefPane project xcode version 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 drawings.

Can someone decrypt the error message so that I can try to fix this problem? I looked through all my layers to make sure the names match.

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:

 <?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:

 <?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> 
+7
source share
4 answers

An Apple developer told me that SMJobBless only works with applications.

+5
source

I also made this mistake, first check the steps declared in the readme.txt file of the SMJobless project again:

  • In the application, go to: Target / Form Phases / Copy files and make sure that the parameters are correctly assigned: Destination = wrapper,
    subpath = Contents / Library / LaunchServices and finally load the daemon or services into the project.
  • In the application, go to the info.plist file and check the following key: "Tools that belong after installation", and configure it to =
    identifier com.acme.MyService and certificate sheet [subject.CN] =
    "MyCertificate". You must replace MyService and MyCertificate with
    your own.
  • In the helper tool or daemon, go to the info.plist file. Here you need to add several key / value pairs, the first of which is: "Clients are allowed to add and remove the tool", which should be set to "identifier
    com.acme.MyApp and certificate sheet [subject.CN] = "MyCertificate"
    , remember, replace MyApp and MyCertificate with your own.
  • Finally, make sure that DAEMON is embedded in the executable file before Build it, this is done as follows: In the auxiliary tool or daemon go to the target / Build Settings / Linking / Other linker flags and add the following:

    -sectcreate
    __TEXT
    __info_plist
    MyDaemon / info.plist
    -sectcreate
    __TEXT
    _launchd_plist
    MyDaemon / myDaemon-launchd.plist

Be sure to replace MyDaemon with the correct values ​​of your own design. Be careful with the names of your information and startup files.

IMPORTANT ADVICE : THE NAME DAEMON OR THE SERVICE SHOULD ONLY CORRESPOND THE NAME WRITTEN IN INFO.PLIST AND LAUNCHD.PLIST FILES SOMETIMES THIS RESOLVES ERROR kSMErrorDomainFramework error 5 - the tool doesn’t kSMErrorDomainFramework on the specified path.

+8
source

This error occurs when the auxiliary tool is not supplied in the right place, so SMJobBless() cannot find the installation tool. In the Build Phases section of your application’s main goal, you must add the Copy Files build phase. Add a helper tool, set the destination to Wrapper and subpath to Contents/Library/LaunchServices , and SMJobBless() can find your helper tool.

+3
source

Check the documentation for SMJobBless for a list of requirements. I assume that you skipped step 1 (signing the code with both the tool and your application) or step 5 (copying the tool to the right place in your application shell).

In addition, [NSString @"com.coderama.coderamaHelper"] does not make sense. Just write @"com.coderama.coderamaHelper" .

If all else fails, look at that code example and follow its example.

+1
source

All Articles