"Precondition failed: NSArray element failed to match the Swift Array Element type" error on iOS version < 13 but works fine on iOS 13 and 14.

I've got a class derived from UIView called ContentListView that goes like this:

It is used in the view controller like this:

But when I tried to run it on iOS 11 and 12 (both simulators and actual devices), it crashed. Although it worked on iOS 13 and 14. It crashed with this error:

Precondition failed: NSArray element failed to match the Swift Array Element type
Expected ContentListView but found UIView: file /BuildRoot/Library/Caches/com.apple.xbs/Sources/swiftlang/swiftlang-1001.0.82.4/swift/stdlib/public/core/ArrayBuffer.swift, line 346
2021-09-22 13:24:27.624568+0700 Kolibree[16970:513272] Precondition failed: NSArray element failed to match the Swift Array Element type
Expected ContentListView but found UIView: file /BuildRoot/Library/Caches/com.apple.xbs/Sources/swiftlang/swiftlang-1001.0.82.4/swift/stdlib/public/core/ArrayBuffer.swift, line 346

The contentListViews in the storyboard themselves are of the type ContentListView so the error seems weird. How do I solve this? It has been days and I'm stuck at this. :(

Thanks in advance.

It looks like the contentListViews items (or some of them in the array) are not defined (in IB) as ContentListView but just UIView.

Check all the elements of the IBOutlet collection in the storyboard.

"Precondition failed: NSArray element failed to match the Swift Array Element type" error on iOS version &lt; 13 but works fine on iOS 13 and 14.
 
 
Q