After updating to the Xcode beta and build/running my app, I started to get an error on all my widgets "Please adopt containerBackground API" and I found a post that had a solution to accommodate iOS 14-16
import Foundation
import SwiftUI
extension View {
@ViewBuilder
func widgetBackground() -> some View {
let gradient = LinearGradient(gradient: Gradient(colors: [Color("LightBlue"), Color("DarkBlue")]), startPoint: .topLeading, endPoint: .bottomTrailing)
if #available(watchOS 10.0, iOSApplicationExtension 17.0, iOS 17.0, macOSApplicationExtension 14.0, *) {
self.containerBackground(gradient, for: .widget)
} else {
self.background(gradient)
}
}
}
I add this to my ZStack for the widget and it does nothing. I still get the same error to adopt to containerBackground API. What am I doing wrong?