Environment:
Xcode Version: 16.0 (latest stable release)
iOS Version: 18.3.1
Devices: physical devices
Configuration: Main Thread Checker enabled (Edit Scheme > Run > Diagnostics)
Issue Description
When the Main Thread Checker is enabled, methods defined in a UIViewController category (e.g., supportedInterfaceOrientations) fail to execute, whereas the subclass implementation of the same method works as expected. This conflicts with the normal behavior where both implementations should be called.
Steps to Reproduce
1、Declare a category method in UIViewController+Extend.m:
// UIViewController+Extend.m
@implementation UIViewController (Extend)
- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
NSLog(@"category supportedInterfaceOrientations hit");
return UIInterfaceOrientationMaskAll;
}
@end
2、Override the same method in a subclass ,call super methed(ViewController.m):
// ViewController.m
@implementation ViewController
- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
NSLog(@"subclass called supportedInterfaceOrientations called");
return [super supportedInterfaceOrientations]; // Expected to call the category implementation
}
@end
3、Expected Behavior (Main Thread Checker disabled):
subclass called supportedInterfaceOrientations called
category supportedInterfaceOrientations hit
4、Actual Behavior (Main Thread Checker enabled):
subclass called supportedInterfaceOrientations called
// category supportedInterfaceOrientations hit
Requested Resolution
Please investigate:
1、Why Main Thread Checker disrupts category method invocation.
2、Whether this is a broader issue affecting other UIKit categories.
Topic:
Developer Tools & Services
SubTopic:
Xcode
Tags:
Linker
Xcode Sanitizers and Runtime Issues
UIKit