我想在 iOS 13 及更高版本上运行此代码我应该如何修复此错误?我想让这段代码也可以在 iOS 13 上运行。
@available(iOS 14.0, *)
@main
struct WeatherProApp: App {
@Environment(\.scenePhase) private var scenePhase
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
var body: some Scene {
WindowGroup{
let fetcher = WeatherFetcher()
let viewModel = WeeklyWeatherViewModel(weatherFethcer: fetcher)
WeeklyWeatherView(viewModel: viewModel)
}
.onChange(of: scenePhase) { (newScenePhase) in
switch newScenePhase {
case .active:
print("scene is now active!")
case .inactive:
print("scene is now inactive!")
case .background:
print("scene is now in the background!")
@unknown default:
print("Apple must have added something new!")
}
}
}
}
但它告诉我这个错误