jana.m
jana.m

Reputation: 31

Unknown class in interface builder + NSUnknownKeyException

I'm building a today extension, which works fine on iOS13+ but somehow it doesn't work for the versions below.

On other versions I get following error:

2019-12-20 08:45:41.741 MyWidget[4730:53043] Unknown class _TtC14MyWidget19TodayViewController in Interface Builder file.

2019-12-20 08:45:41.850 MyWidget[4730:53043] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x7ffe59401f10> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key loginViewNew.'

At first I thought it was caused, because in the properties under Interface Builder Document builds for was set to iOS13 and later, so I changed this in my storyboard and all my other .xib files but this did not solve the problem, I still get the same error.

I also checked my outlets and there are no errors there as well, storyboard can find my TodayViewController class so I have no clue what the problem can be.

It does not only occur for the key loginViewNew, if I delete that outlet the error mentions the next view and so on.

Does anyone have suggestions for solving this problem?

Upvotes: 1

Views: 288

Answers (1)

Denis Oliveira
Denis Oliveira

Reputation: 582

Some cases generate an Unknown class in Interface Builder file after Xcode 11 with a target below iOS 13. The main cause it's related to xcframeworks this is so expected because when building a framework for distribution required changes to the Objective-C runtime that are only available in iOS 13 and later. The following samples on how to reproduce the unknown class.

  • public enum exported by framework and used as attribute on class:
// SampleEnum exported on framework
public enum SampleEnum: String {
  case A = "a"
  case B = "b"
}

// SampleViewController on your current target
public class SampleViewController: UIViewController {
  private var sampleEnum: SampleEnum = .A
}

// Causes Unknown class _TtC6Sample20SampleViewController in Interface Builder file.
  • inheritance of inheritance as:
// Base BaseViewControoler exported on framework
public class BaseViewController: UIViewController {
}

// ScreenAViewController on your current project
public class ScreenAViewController: BaseViewController {
}

// Causes Unknown class _TtC6Sample21ScreenAViewController in Interface Builder file.
  • small issues on interface builder on Show the Identify inspector section Custom Class fields:

Class

Module

Inherit Module From Target

Upvotes: 1

Related Questions