returned nil from -traitCollection, which is not allowed in Xcode 11 Beta
Asked Answered
S

3

7

Assertion failure in UITraitCollection * _Nonnull returned nil from -traitCollection, which is not allowed? when I try to run Xcode 11 beta in ios 13 it crashed. I don't know what was wrong.

Supporter answered 16/9, 2019 at 2:0 Comment(7)
you need to add some code. From what I gather, you are maybe trying to modify a constraint's value but the IBOutlet against the same is not created or not connected.Remissible
now I got a solution by add some code DispatchQueue.main.asyn{ //code } after featch DataSupporter
Good to know. Glad you worked that out :)Remissible
I have the same issue. Can you post a detailed answer?Fore
I try to debug the class that crashed and put DispatchQueue.main.asyn{ //code } on method or statement of code that I'm Suspected​​ it will crashed one by one so the problem was solved.Supporter
example//--Add pull to refresh DispatchQueue.main.async{self.myTableview.addSubview(self.refreshControl)}Supporter
Same issue here, I have this assert in one of my tests when trying to initialise a UIActivityIndicatorView in the main thread...Barneybarnhart
S
12

[super init]

I ran across this problem because one of the unnamed previous coders on my codebase, whom I frequently curse, didn't call [super init] on a class that implements the UITraitEnvironment (aka UIView or UIViewController)!

If I could wield a battle hammer backwards five years in time, I would.

This implementation in a subclass of UIViewController

- (id)initWithStartPositionPdf:(float)startPosition withScrollViewHeight:(float)scrollViewHeight {
    _startPosition = startPosition;
    _scrollViewHeight = scrollViewHeight;

    self.isPdfView = YES;

    return self;
}

was updated to…

- (instancetype)initWithStartPositionPdf:(float)startPosition withScrollViewHeight:(float)scrollViewHeight {
    self = [super initWithNibName:nil bundle:nil];
    _startPosition = startPosition;
    _scrollViewHeight = scrollViewHeight;
    _isPdfView = YES;
    return self;
}

and resolved the crash I started receiving in Xcode 11 / iOS 13.

Standush answered 27/11, 2019 at 19:37 Comment(2)
Thanks, this helped me. And also updating an app written by someone else...Harbert
Id upvote this a million times if I could. I spent many hours trying to figure this out. Thank you.Bronchia
V
3

This is how iOS 13 and Xcode 11 deal with the main thread checker inconsistencies.

basically, you are updating the UI from a background thread. Just make sure you're updating all your UI in the main thread.

Simply wrap the code that updates your UI inside DispatchQueue.main.async { }.

Vogele answered 25/9, 2019 at 18:33 Comment(0)
F
1

Just simple put your code in main thread of UI update :

DispatchQueue.main.async
             {
          // Put your code here 
           }
Frisby answered 1/10, 2019 at 7:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.