Can't test HomeKit within the simulator

I'm struggling quite a bit trying to even get started on poking around with HomeKit within the iOS simulator.

I'm using Xcode 13.1 and attempting to simply add a new home. I'm listening for homeManagerDidUpdateHomes, then calling addHome(withName:completionHandler:) to even have a home in the first place to begin testing with.

This fundamental step completely fails in the simulator with the following error:

Error Domain=HMErrorDomain Code=2 "Object not found." UserInfo={NSLocalizedDescription=Object not found.}

I then tried Apple's sample app here just to see if it was something in my code, but it fails in exactly the same fashion when adding the first home. https://developer.apple.com/documentation/homekit/interacting_with_a_home_automation_network

Is this a known bug? What could be preventing HomeKit from working within the simulator?

Answered by jonathan_w in 697918022

This seems to be improved in Xcode 13.2 GM — I can now successfully add an empty home.

Having the same issue with this example app: https://developer.apple.com/documentation/homekit/configuring_a_home_automation_device

When I launch the simulator and add the first home, I get Error adding home: Error Domain=HMErrorDomain Code=2 "Object not found." UserInfo={NSLocalizedDescription=Object not found.}

I do not get this error when I run it on my own physical device, so there might be an issue with the simulator.

Yes, I can also confirm it works on device. Not the end of the world I suppose, but I'd prefer to be using the simulator for tests.

Accepted Answer

This seems to be improved in Xcode 13.2 GM — I can now successfully add an empty home.

Can't test HomeKit within the simulator
 
 
Q