How can I use the dialogIcon
view modifier that was introduced for Mac Catalyst 17? I get this error message 'dialogIcon' is unavailable in iOS
compiling with Xcode 15.0.1 on Mac 13.6 targeting Mac (Mac Catalyst) with both Mac Catalyst Interface=Scaled to Match iPad or Optimized for Mac. Thank you
import SwiftUI
struct DialogIcon: ViewModifier {
let icon: String
func body(content: Content) -> some View {
#if targetEnvironment(macCatalyst)
if #available(macCatalyst 17.0, *) {
content
.dialogIcon(Image(systemName: icon))
} else {
content
}
#else
content
#endif
}
}
extension View {
func dialogIconModifier(icon: String) -> some View {
modifier(DialogIcon(icon: icon))
}
}
While I can't verify what the issue is on Xcode 15.0.1, the error does not exist with Xcode 15.1. So upgrading to Xcode 15.1 will resolve your issue.
It's possible Apple didn't properly mark the API as available for Mac Catalyst in Xcode 15.0.1 and they fixed it with Xcode 15.1. This would not be the first time I've seem them forget to properly update an API availability for Mac Catalyst.