NSMuatableAttributedString's appendString method only exist in iPhone-device build in iOS18, and not exist in Simulator-build

I have defined a method appendString method in a NSMuatableAttributedString category like this:

@implementation NSMutableAttributedString (HTML)


// appends a plain string extending the attributes at this position
- (void)appendString:(NSString *)string
{
    NSParameterAssert(string);
    
    NSUInteger length = [self length];
...

And this method is worked well in iOS17 and before .

But when it cames iOS18 . this appendString will not be called.

So I doubt maybe there is a system-defined appendString already.

So I write a demo in empty project to print all the NSMuatableAttributedString method in iOS18 like these:

@interface ViewController ()

@end

@implementation ViewController

void printNSStringCategories() {
    unsigned int count;
    Class nsStringClass = [NSMutableAttributedString class];

    
    // 获取所有的方法
    Method *methods = class_copyMethodList(nsStringClass, &count);
    
    for (unsigned int i = 0; i < count; i++) {
        SEL selector = method_getName(methods[i]);
        NSString *methodName = NSStringFromSelector(selector);
        NSLog(@"NSMutableAttributedString method: %@", methodName);
    }
    
    free(methods);
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    printNSStringCategories();
}

And test it in my iPhone (iOS18.2) , the log will printed

NSMutableAttributedString method: appendString:withAttributes:
NSMutableAttributedString method: cr_appendStorage:fromRange:
NSMutableAttributedString method: cr_appendString:
NSMutableAttributedString method: appendString:withAttributes:
NSMutableAttributedString method: appendString:

So it seems a appendString: is aleady defined in system SDK .

But the weird thing is when I run this code in the Xcode simulator (iOS18.1) this appendString: will not print .

1 Is it a bug of SDK ? because the appendString: only exist in device-build , and not exist in simulator-build?

two more furthur question:

2.1 if the SDK contains appendString: already , why the appendString: defined in my category not cause the duplicate symbol error when compile

2.2 As the question 2.1 said , there maybe same symbols in runtime . Is there any way to find the framework/library which defined those same-name symbols ? (e.g: there are two appendString:withAttributes: in the log , I want to find the two places define each appendString:withAttributes: exactly)

To avoid such things randomly exploding, it's better to add a three letter prefix to each category method of system classes.

Objective-C has got no namespaces, so if you add a category to a system class, and then Apple implements something with the same name, bad things happen™.

Maybe Apple's symbol it's in a library that's not loaded in the simulator? The simulator it's not an emulator, so often there are many differences.

NSMuatableAttributedString's appendString method only exist in iPhone-device build in iOS18, and not exist in Simulator-build
 
 
Q