Fix iOS Deployment Target 13 (still working for iOS 12)#774
Conversation
|
LGTM! Thank you |
|
@EricBeetsOfficial-Opuscope Is it ok to merge ? |
| #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_13_0) | ||
| return [[[[sharedApplication windows] firstObject] windowScene] interfaceOrientation]; | ||
| #else | ||
| return [sharedApplication statusBarOrientation]; |
There was a problem hiding this comment.
Should we keep the runtime @available check in the else case since we might still be running on an iOS version >= to 13?
There was a problem hiding this comment.
Previously, we required at least the iOS 13 SDK to compile, but at runtime it would work on iOS 13 (using window.windowScene.interfaceOrientation) or iOS <13 (using [[UIApplication sharedApplication] statusBarOrientation]). Is that right?
Is this change trying to make it so you can compile the code against an older SDK that doesn't know anything about sharedApplication.windows.firstObject or window.windowScene.interfaceOrientation?
There was a problem hiding this comment.
I changed the @available for a conditional compilation because on iOS 13.0, it didn't compile: 'statusBarOrientation' was deprecated in iOS 13.0 error. (I would have liked keep @available which was more elegant :p)
There was a problem hiding this comment.
Oh I see, so basically if you target a high enough iOS version (13 in this case), then some older APIs ([sharedApplication statusBarOrientation] in this case) are no longer available and result in compile errors, correct? If that is the case, then I think we still want to use the newer API if at runtime we see that we are running on a newer OS version, which I think is exactly what @Alex-MSFT is saying above. So something like:
UIApplication* sharedApplication = [UIApplication sharedApplication];
#if (__IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_13_0)
if (!@available(iOS 13.0, *)) {
return [sharedApplication statusBarOrientation];
}
#else
return [[[[sharedApplication windows] firstObject] windowScene] interfaceOrientation];
#endifSo basically only use statusBarOrientation if we are both compiling for a target less than 13, and running on a device that is less than 13.
There was a problem hiding this comment.
I think what Ryan shared makes the most sense, that way we can still always take advantage of the newer interfaceOrientation API when running on iOS 13.0 or later no matter what the min version is.
There was a problem hiding this comment.
Im afraid that if(!@available(..)) is not allowed. I suggest you this :
UIApplication* sharedApplication = [UIApplication sharedApplication];
#if (__IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_13_0)
return [[[[sharedApplication windows] firstObject] windowScene] interfaceOrientation];
#else
if (@available(iOS 13.0, *)) {
return [[[[sharedApplication windows] firstObject] windowScene] interfaceOrientation];
}
else {
return [sharedApplication statusBarOrientation];
}
#endif
There was a problem hiding this comment.
Ok I think that is reasonable. I was trying to avoid duplicating that line, but I think my logic was actually wrong anyway. Thanks for making this contribution!
There was a problem hiding this comment.
Yeap, I would also have liked to avoid duplicating these lines :|
No description provided.