I’m trying to bridge SwiftUI with ObjectiveC (A minimum reproducible example at the bottom).
Considering the below structure.
Why does the Test2.mm fails to build with the error and what can be done?:
No known class method for selector 'stringWithString:'
Test_header.h:
#ifndef Test_header_h
#define Test_header_h
#import <Foundation/Foundation.h>
@interface XC: NSObject
- (void) f;
@end
@interface XD: NSObject
- (void) f;
@end
#endif /* Test_header_h */
Test.m:
#import <Foundation/Foundation.h>
#include "Test_header.h"
@implementation XC
- (void) f
{
[NSString stringWithString:@"x"];
}
@end
Test2.mm:
#import <Foundation/Foundation.h>
#include “Test_header.h”
@implementation XD
- (void) f
{
[NSString stringWithString:@"x"];
}
@end
The minimum reproducible example: https://github.com/cosmin42/BridgingSample