Hi,
I'm trying to build a react native project on Xcode 10.1 with IOS 12.1. I am using Mac OS 10.13.6 (hence the old Xcode). Whenever I build it, these errors appear regarding the @available(iOS 13.0, *) condition.
The path to the below error: Pods > Development Pods > react-native-maps > AIRMAP.m > -setUserInterfaceStyle:
- (void)setUserInterfaceStyle:(NSString*)userInterfaceStyle
{
if (@available(iOS 13.0, *)) {
if([userInterfaceStyle isEqualToString:@"light"]) {
self.overrideUserInterfaceStyle = UIUserInterfaceStyleLight;
} else if([userInterfaceStyle isEqualToString:@"dark"]) {
self.overrideUserInterfaceStyle = UIUserInterfaceStyleDark;
} else {
self.overrideUserInterfaceStyle = UIUserInterfaceStyleUnspecified;
}
} else {
NSLog(@"UserInterfaceStyle not supported below iOS 13");
}
}
I understand why it is failing, properties such as overrideUserInteraceStyle don't exist pre IOS 13 dark mode. However, I don't understand why the @available tag is not preventing Xcode from entering that code block. I have tried New Build & Legacy Build. I have set the project format to Xcode 10.0-compatible. Xcode 9.4+ should support @available.
How can I resolve this error on Xcode (other than by commenting it out)?
@available requires that the symbols in the code block are available in the sdk. If you are using a previous sdk, you have to fall back to the good old C preprocessor and disable the code block. @available is not a way to make it possible to compile code that requires a newer sdk on an older Xcode version.