While here Apple states that the Swift available
flag should be applied also in objc, it's not working for me. What am I doing wrong?
I've got following declarations in Swift files:
@objc protocol Readable: AnyObject {...}
@available(iOS 10.3, *)
@objc class Reader: NSObject, Readable {...}
So let's check if it produces an error when I try to initialize it in pre-ios-10 project without version check. If I write following code in Swift:
let tmp = Reader()
it returns an error:
'Reader' is only available on iOS 10.3 or newer
What is expected.
However if I write following code in objc:
// if (@available(iOS 10.3, *)) { // commeted out to test if it succeeds without version check
Reader *tmp = [[Reader alloc] init];
// }
The build is finished without any error, while I'd expect the same error as in Swift.
I've tried to mark the class with:
- @available(iOS 11, *)
- @available(iOS, introduced: 10.3)
Neither of these works (produces an error) in objc. Any help, please?