23

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?

Community
  • 1
  • 1
JSA986
  • 5,870
  • 9
  • 45
  • 91

17 Answers17

42

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

  • This was my issue, Module wasn't set for some odd reason. Using the new Xcode 7. – Ruben Martinez Jr. Jun 13 '15 at 18:32
  • 2
    This was also my issue, however I didnt get how to change the module with your description. The module option is found in the Interface Builder, right panel, the third tab, right below the Class option. – Juan Haladjian Apr 26 '16 at 18:02
  • 1
    Part 2 was the solution for me. I had replaced an ObjC file with a Swift file, and of course Swift files need a module. – lewis Dec 11 '18 at 15:31
  • What in case when you have multiple targets for WatchKit/WatchKitExtensions? I can put there only one module, but I have 4 different targets for WatchKit/WatchKitExtensions (together 8 targets). – Ariel Bogdziewicz May 06 '19 at 10:00
  • Ok, I solved it for multiple targets by WatchKitTargetApp[1-N] -> Build Settings -> Interface Builder Storyboard Compiler -> Default Module must be set to WatchKitExtensionModule[1-N] and in Storyboard you have to check Inherit Module From Target. – Ariel Bogdziewicz May 06 '19 at 10:21
  • I renamed the target and failed to update the module field in Storyboard. Thanks. – Friendtam May 17 '19 at 11:54
25

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.

JSA986
  • 5,870
  • 9
  • 45
  • 91
16

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".

devone
  • 293
  • 3
  • 10
  • 1
    This was a big help for me... same issue and nothing else worked, thanks! – GarySabo Jul 24 '15 at 21:30
  • 2
    I had this issue after copying an InterfaceController from an existing project into the current project. Fixed by changing the module back to none/empty. Thanks. – mumush Aug 03 '15 at 06:50
12

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

Shrawan
  • 7,128
  • 4
  • 29
  • 40
2

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

Community
  • 1
  • 1
tt.Kilew
  • 5,954
  • 2
  • 33
  • 51
2
1. select your WKInterfaceController
2. select Inherit Module From Target

enter image description here enter image description here

Kamani Jasmin
  • 691
  • 8
  • 11
2

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

kenlukas
  • 3,616
  • 9
  • 25
  • 36
kyhai
  • 21
  • 3
1

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

VaporwareWolf
  • 10,143
  • 10
  • 54
  • 80
1

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

zaolian
  • 1,187
  • 3
  • 11
  • 21
  • This has already been answered correctly and marked as correct "class must be set to the correct target membership" it is not a compile resources issue – JSA986 Jan 28 '16 at 10:17
  • @JSA986 Thanks for the comment! I ran into the problem and the above correct answer was not detailed enough for me to solve it. It tells me Why, but not How. Thus I think writing the steps here might be useful to people new to iOS development. – zaolian Jan 28 '16 at 17:30
1

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!

Josh
  • 6,251
  • 2
  • 46
  • 73
1

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

Ali
  • 514
  • 5
  • 16
1

I solved it by setting Module to Watch_Extension

rgreso
  • 496
  • 1
  • 7
  • 19
0

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

kavehmb
  • 9,822
  • 1
  • 19
  • 22
0

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

basvk
  • 4,437
  • 3
  • 29
  • 49
0

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

swiftyboi
  • 2,965
  • 4
  • 25
  • 52
0

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

Evan
  • 1,152
  • 1
  • 11
  • 18
0

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.

Developersian
  • 151
  • 2
  • 7