Xcode's fix-its like to insert code like this:
if #available(iOSApplicationExtension 15.0, *) {
// Use some iOS 15 API here.
}
Usually, I just change those to this:
if #available(iOS 15.0, *) {
// Use some iOS 15 API here.
}
It's not clear to me, though, what the difference between the two is. Is iOSApplicationExtension
more or less restrictive than iOS
? Are there APIs that you could only call within the first block above?
There are some APIs that are marked unavailable in extensions, but they don't seem to be affected by this attribute. This, for example, compiles just fine:
if #available(iOSApplicationExtension 15.0, *) {
// This is marked NS_EXTENSION_UNAVAILABLE_IOS
print(UIApplication.shared)
}
So what's the difference?