Assert Current fallback trait collection contains one or more unspecified traits:

I had the same issue here because I was overriding the traitCollection property (which is not recommended by Apple but I didn't find any other solution in my case) and the new traitCollection I returned has many unspecified traits (as the error message said).

So now I return a new traitCollection object but I initialize it by adding super.traitCollection. So in my view controller I have something like:

public override var traitCollection: UITraitCollection {
    var newTraitCollection: [UITraitCollection] = [super.traitCollection]
    // I need to force size class on iPad
    if UIDevice.current.userInterfaceIdiom == .pad {
        newTraitCollection += [UITraitCollection(verticalSizeClass: .regular), UITraitCollection(horizontalSizeClass: .compact)]
    }
    return UITraitCollection(traitsFrom: newTraitCollection)
}

UITraitCollection has change in iOS13. U can find out where this class has been used.

eg: remove this method [UITraitCollection traitCollectionWithHorizontalSizeClass:UIUserInterfaceSizeClassUnspecified]

Tags:

Xcode11

Ios13