Storyboard custom view class "Unknown class in Interface Builder file." and crash

I am having a bizarre problem relating to having an application and a framework (it's what we need to do for Watch or Today, or etc, right?), and a Swift view class I moved from the application to the framework. Because, Watch or Today, or etc..


What's bizarre is, I literally moved the class from the app to the framework, I didn't modify the source code outside of adding a handful of "public" in front of the class name and related methods so that compilation would chill out. It was compiling and rendering cleanly for the application in the simulator, which has a main storyboard and a separate storyboard using the new storyboard reference feature. All targets except the legacy target (the application I am replacing) are iOS 9. I should mention that the class happens to have the same class name of a class in a legacy target that is Objective-C based, but neither the new target nor the framework are Objective-C based, both are pure Swift (yay, me!), and there is no relation to the legacy target.


OK. So the problem. The main.storyboard happily soaks up the moved class, and renders it OK after the move. But when the storyboard reference loads a view controller containing the exact same class name, with the same Module name (the framework), it first logs "Unknown class <yadda-yadda-deleted> in Interface Builder file." and then promptly crashes (SEGV) attempting to accessing anything in the missing class.


This is a fairly infuriating prolem. I don't know how to move forward. I saw on stackoverflow that there was a similar problem in Xcode 6 where if the Module name wasn't set, it might crash in a way like this. Only, both in the Main storyboard and the stoaryboard reference, the Module name is set. What gives?


I'm not particularly inclined to figure out how to report this in standalone code to bugreporter, I'm much more keen to get advice, if anyone else has run into a similar problem and successfully worked around it.

Accepted Reply

You've made sure that it's exactly the same in both storyboards, right? Did you forget to change it anywhere?

Replies

Couple of updates:


I renamed the class to eliminate the possibility that the legacy target or Objective-C class name was having an effect. No dice, still crashed the same with the new class name in the Swift file and both storyboards.


I also tried adding "@objc(MyViewClass)" in front of "class MyViewClass: UIView ...", in response to one of the stackoverflow posts that claimed this cures the Xcode 6 troubles, and all that did was move the crash from the secondary storyboard to the main storyboard.


So, recapping: I can make either the main storyboard or a storyboard-referenced storyboard in a Swift-only application and framework, get confuzzled if the view exists in the framework? Anyone? Bueller?

You've made sure that it's exactly the same in both storyboards, right? Did you forget to change it anywhere?

Ah. I forgot about another controller in the referenced storyboard, and that one has a cell prototype with the view class, but without the module name. Fixing the module name and undoing the previous attempted workaround enabled the storyboard reference to work.

Glad to hear it. It's always nice when scary-looking issues turn out to be simple to fix! 🙂

_