I'm using Xcode 11 on the GM build of Catalina (10.15). I'm working on building my iOS app for Mac Catalyst. My iOS app has a deployment target of iOS 11.
I have a simple line in a view controller such as:
self.modalInPopover = YES;
Compiles clean in iOS. When I switch to the "My Mac" destination, I get a deprecation warning:
'modalInPopover' is deprecated: first deprecated in macCatalyst 13.0
OK, fine. I can switch to the new method added in iOS 13:
if (@available(iOS 13.0, *)) {
self.modalInPresentation = YES;
} else {
self.modalInPopover = YES;
}
That should fix it but I still get the same deprecation warning on the use of modalInPopover
in the else
block.
What's odd is that the corresponding Swift code does not give any warnings. Only the Objective-C code continues to give the warning.
if #available(iOS 13, *) {
self.isModalInPresentation = true
} else {
self.isModalInPopover = true
}
I even tried updating the @available
to:
if (@available(iOS 13.0, macCatalyst 13.0, *)) {
but that didn't change anything.
The following disaster solves the problem but it shouldn't be needed:
#if TARGET_OS_MACCATALYST
self.modalInPresentation = YES;
#else
if (@available(iOS 13.0, *)) {
self.modalInPresentation = YES;
} else {
self.modalInPopover = YES;
}
#endif
Am I missing something or is this an Xcode bug? How can I eliminate the deprecation warning in Objective-C without duplicating code using #if TARGET_OS_MACCATALYST
which isn't need in Swift.