Hi I'm trying to add a home to the database, but i get an error.
[self.homeManager addHomeWithName:@"Enfield" completionHandler:^(HMHome *home, NSError *error)
{
if (error != nil) {
NSLog(@"Unable to add home. \n%@", error);
} else {
NSLog(@"Home added Sucessfully \n%@", home);
}
}];
I get an error:
Error Domain=NSCocoaErrorDomain Code=4097 "The operation couldn’t be completed. (Cocoa error 4097.)" (connection to service named com.apple.homed.xpc) UserInfo=0x7f9e9b965290 {NSDebugDescription=connection to service named com.apple.homed.xpc}
I looked in other posts and it looks like you have to have Developer ID, but that just doesn't make sense Apple allows to develop everything without an ID, but not the HomeKit. Can someone please shed a light on this.
EDIT:
GitHub link https://github.com/zlDev/HomeKitDemo
NinjaEDIT: Some code
To see if you got an error, don't test error
. Instead, the test should be
if (home == nil) {
If there is an error, then error
points to a description of the error; if there was not an error, error
may be nil or may point to garbage.
OK, I dug a little deeper.
The error connection to service named com.apple.homed.xpc
means that Xcode cannot connect to the HomeKit Accessory Simulator, which it would normally do through the Mach port named com.apple.homed.xpc. (The .xpc is the clue that this is for program-to-program commnunication. It's not a URL.)
The HomeKit documentation says that to start the HK Simulator, you need to add HomeKit to the list of your project's capabilities, and then use the menu command Xcode→Open Developer Tool→HomeKit Accessory Simulator. When I created a dummy iOS project and tried to add the HomeKit capability, Xcode at first refused because I had not yet agreed to Apple's latest terms of service.
Which answers your question. You cannot turn on the HomeKit capability without an Apple Developer ID.
What it doesn't answer is whether the developer ID has to be a paid developer ID. It might suffice to set up a free developer ID. That gives Apple a mechanism to get your agreement to Apple's terms of service, and might be all they need for now.
But even after I finally got the HomeKit capability turned on, the menu command was not available. Apparently you need to also go to developer.apple.com/downloads and download "Hardware IO Tools for Xcode 6.1", which includes the HomeKit Accessory Simulator". You will need an Apple Developer ID (of some level) to download the file.