iosswifthomekit

HMHomeManager homes is empty


I'm creating an instance of HMHomeManager, registering the delegate, waiting until homeManegerDidUpdateHomes() is called, but when I read manager.homes, it returns an empty array.

I tried checking the following:

Nothing seems to work, though.


Solution

  • Turns out it's not enough to enable all those settings. You also need to go to the Capabilities tab of your project, and enable HomeKit. Otherwise manager.homes.count will be zero, and manager.primaryHome will be nil.