Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HomeKit - Error Domain=NSCocoaErrorDomain Code=4097

I would like to create HMHome with HMHomeManager and addHomeWithName.

manager.addHomeWithName("Casa", completionHandler:
{
    (home:HMHome!, error:NSError!) in
    if error != nil {
        NSLog("Failed adding home, Error:\(error)")
    } else {
        NSLog("New Home \(home)")
    }
})

When the application is run I am getting the following error instead of creating Home

Failed adding home, Error:Error Domain=NSCocoaErrorDomain Code=4097
"The operation couldn’t be completed. (Cocoa error 4097.)"
(connection to service named com.apple.homed.xpc)

I read than this problem can be solved switching "HomeKit" to "On" at the "Capabilities" tab. But I don't have a developer ID that is enrolled in a Developer Program.

There is any way to use this functionality without pay 80€/year?? I only want to learn... There is any way to enroll my Apple ID in free mode?

Thanks for all!!

like image 593
KameHouse Avatar asked Oct 05 '14 20:10

KameHouse


2 Answers

Turning on "Homekit" on the capabilities tab says it will do three things -

  1. Add the Homekit entitlement to your app id
  2. Add the Homekit entitlement to your entitlements file
  3. Link the Homekit framework

You can't do 1 without the developer membership, but you can do 2 & 3 manually.

  1. Select a folder in your project, such as "Supporting files" and select File->New->File (or Cmd-N)
  2. Select "Resource" from the iOS section and then select "Property List" and click "Next"
  3. Name the file "yourProject.entitlements" and click "Create"
  4. Select the first line in newly created file ("Entitlements file") and click the + to add a new entry
  5. Enter "com.apple.developer.homekit" with type "Boolean" and value "YES"
  6. Select your Xcode project (Blue icon) at the top of the project navigator and go the "General" tab
  7. At the bottom your will see "Linked Frameworks and Binaries". Click "+" and add the Homekit.framework

Unfortunately this still gave me the same error you received, until I enabled Homekit in capabilities, so it seems you will need to get a paid developer membership to work with Homekit

like image 71
Paulw11 Avatar answered Oct 13 '22 12:10

Paulw11


Hello again and thanks for answering.

I answer myself. I managed to run my code running it from the Xcode 6 beta 3. In xcode 6 betas 1-3 you did not need any special capabilities To have to use homekit. This Beta 4 changed. You need to Have the homekit Both entitlement added to your entitlements file and your app ID.

To learn is perfect. and if I decide to take the step to the AppStore, I enroll in the Apple Developer Program.

like image 22
KameHouse Avatar answered Oct 13 '22 12:10

KameHouse