JSA986
JSA986

Reputation: 5936

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

Whenever I make any connections in my subclass of WKIInterfaceController I get error WatchKit error - unable to find interface controller class 'myClass' to instantiate and a activity indicator showing in simulator and the view does not load. Disconnect all conections and the view displays correctly but still get the error

Tried

Unable to find interface controller class 'InterfaceController' to instantiate

WatchKit: unable to find interface controller class

WatchKit reloadRootControllersWithNames causing error, with pageController or after push/pop

Two links suggests a bug, If it is a bug this would surely not be present on the release version of XCode and everyone would experience the same behaviour rendering watcKit all but useless?

Upvotes: 23

Views: 12525

Answers (17)

Developersian
Developersian

Reputation: 161

the accepted answer didn't work for me.

I did answer it completely In this post: https://stackoverflow.com/a/61517773/7345611

but I did put the part related to this question here:

The best approach that worked for me is:

  1. go to interface.storyboard located at left navigator pane in Xcode

  2. select the yellow circle on top of a interfaceController

  3. go to it's identity inspector
  4. in class section, reassign your class to that interfaceController by retyping the class name and hitting enter which Xcode will updates the module section under it automatically. (all your problem lie in Module Section where Module still has the old name assigned to it)
  5. do the same process for all interfaceControllers and customClasses(if you have any) and everything that you assigned a class to it before.

now the app should run as expected.

Upvotes: 0

Evan
Evan

Reputation: 1312

Make sure the module name in storyboard is same as .appex file under tagerts/XXX WatchKit App General Tab -> Frameworks, Libraries, and Embedded Content.

Upvotes: 0

swiftyboi
swiftyboi

Reputation: 3221

Just drove myself nuts over this for a couple of hours. Followed all the suggestions here, no luck.

What ended up for me is what I should have done in the first place - I cleaned the build folder.

Product > Clean Build Folder

Upvotes: 0

kyhai
kyhai

Reputation: 21

The problem here is that we set the module for the interface controllers incorrectly. Since those controllers belong to Watch Extension target, we can find the product module as below

Image to show how to find the product module name

image to show how to find the product module name

Once we have the module name, just go ahead and set it for each interface controller

image to show how to set the product name

image to show how to set the product name

Upvotes: 2

Kamani Jasmin
Kamani Jasmin

Reputation: 711

1. select your WKInterfaceController
2. select Inherit Module From Target

enter image description here enter image description here

Upvotes: 2

Shrawan
Shrawan

Reputation: 7246

After adding new Interface controller in WatchOS, above issue is occurred due to wrong

"Module Name in Custom Class" :-

enter image description here

After changing the module to extension above issue is resolved.

enter image description here

Upvotes: 12

rgreso
rgreso

Reputation: 542

I solved it by setting Module to Watch_Extension

Upvotes: 1

Ali
Ali

Reputation: 514

Just look target for both class and interface. It should be set to Extension that's all

Upvotes: 1

Josh
Josh

Reputation: 6373

Clicking in my Watch storyboard > Interface controller Scene > Identity Inspector (the middle icon, from the 5 icons that appear on the menu at the right of Xcode) > Set Module to "[YourProjectName]Extension" worked for me!

Upvotes: 1

zaolian
zaolian

Reputation: 1197

You need to verify the view controller is in your compile source here: Select Project > Select Watchkit Extension Target > Build Phases > Compile Sources

Upvotes: 1

z2k
z2k

Reputation: 10380

When you create your glance interface controller, be sure to add it to the the Watch App Extension. This was my problem.

Upvotes: 1

basvk
basvk

Reputation: 4546

I fixed it by clearing the module name in the storyboard for that specific interface class. (Which is a objective-c class).

Upvotes: 0

kavehmb
kavehmb

Reputation: 9913

Make sure you make the new Class member of the EXTENSIONS while you are creating the class.

Upvotes: 0

tt.Kilew
tt.Kilew

Reputation: 6084

In my case I renamed Watch Kit Extension to WatchKitExtension, and it was running succesfully on simulator, but failed to run after full project clean.
Thanks to https://stackoverflow.com/a/29904047/104170.
In order to make it work I just needed to specify correct module in my .storyboard file

Upvotes: 2

Aleksandr Shcherbakov
Aleksandr Shcherbakov

Reputation: 769

I solved this issue by:

1) deleting trouble-making InterfaceController file and creating it again in the folder for WatchKit Extension in the project (not just in a group in Project navigator). By default xcode gives you Watch App folder - you have to change it.

2) setting class in Interface Builder so that module was set to ProjectName_WatchKit_Extension

If module is not set - xcode won't be able to find your class

Upvotes: 42

JSA986
JSA986

Reputation: 5936

For anyone else who has this. The class must be set to the correct target membership ie yourApp WatchKit Extension rather than yourApp WatchKit App when creating your class. It can also be edited in Target membership in interface builder.

Upvotes: 25

devone
devone

Reputation: 293

I was having same issues after the recent 8.2 release. I had to go to each one of my InterfaceControllers and adjust its custom class module to whatever was shown as an option or "none".

Upvotes: 16

Related Questions