Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WatchKit: unable to find interface controller class

I tried adding an interface controller to a storyboard, setting its Custom Class to a WKInterfaceController subclass, launched the app in the simulator and navigated to the specified interface controller.

When I do so, I get the following error:

WatchKit error - unable to find interface controller class 'TestController' to instantiate

If I try to interact with the controller (e.g. try launching its button's action), I get the following error:

  • *********** ERROR -[SPRemoteInterface _interfaceControllerClientIDForControllerID:] clientIdentifier for interfaceControllerID:(null) not found
  • *********** ERROR -[SPRemoteInterface _interfaceControllerClientIDForControllerID:] clientIdentifier for interfaceControllerID:7120004 not found

I tried setting the module name as recommended on this answer, but that still gives me the following errors:

  • WatchKit error - unable to find interface controller class '_TtC29myWatchApp_WatchKit_App19TestController' to instantiate
  • *********** ERROR -[SPRemoteInterface _interfaceControllerClientIDForControllerID:] clientIdentifier for interfaceControllerID:(null) not found
  • *********** ERROR -[SPRemoteInterface _interfaceControllerClientIDForControllerID:] clientIdentifier for interfaceControllerID:6E20004 not found
like image 442
Senseful Avatar asked Mar 16 '15 03:03

Senseful


3 Answers

I got this error after renaming the WatchKit target, but finally realized: if you rename your WatchKit targets, you'll have to go through the interfaces in Interface Builder and make sure the module names for each of them is renamed as well.

You can do this by selecting an interface controller, clicking the Identity Inspector (or command-option-3), delete the module name, then tab away. It will automatically be filled in with the new target name. That did it for me!

like image 175
Canucklesandwich Avatar answered Nov 05 '22 17:11

Canucklesandwich


This error came up for me because I was not properly handling the didDeactivate message. My deactivated controller was still receiving messages via MMWormhole. Once I severed that connection, the error went away. It turns out that in the simulator all the deactivated interface controllers hang around in memory, so you have to carefully make sure they don't get any more messages of any kind. I don't know if this happens on the Watch itself, but of course we should assume so.

like image 16
phatmann Avatar answered Nov 05 '22 17:11

phatmann


I spent way too much time with this issue, but finally figured what it was. The Apple Watch has basically two navigation patterns:

Hierarchical:

[self pushControllerWithName:@"controllerName" context:nil];

Page-based:

[[self class] reloadRootControllersWithNames:@[@"controller1",@"controller2"] contexts:nil];

According to apple:

You cannot combine hierarchical and page-based interface styles. At design time, you must choose the style that best suits your app’s content and design for that style.

So, the issue is that I was mixing both and that leads to undefined behavior like:

*********** ERROR -[SPRemoteInterface _interfaceControllerClientIDForControllerID:] clientIdentifier for interfaceControllerID:(null) not found

Hope this helps other developers

EDIT:

Just a suggestion that worked for me as a workaround, when using Page-based navigation you can still present modal controllers (just saying):

[self presentControllerWithName:@"controllerName" context:nil];
like image 11
topes Avatar answered Nov 05 '22 16:11

topes