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

故事扮演 提交于 2019-11-29 16:41:10

问题


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?


回答1:


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




回答2:


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.




回答3:


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




回答4:


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

"Module Name in Custom Class" :-

After changing the module to extension above issue is resolved.




回答5:


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




回答6:


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




回答7:


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




回答8:


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




回答9:


I solved it by setting Module to Watch_Extension




回答10:


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

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




回答11:


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




回答12:


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




回答13:


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!




回答14:


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




回答15:


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




回答16:


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



来源:https://stackoverflow.com/questions/29121727/watchkit-error-unable-to-find-interface-controller-class-to-instantiate

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!