相关疑难解决方法(0)

在 Xcode 12 中使用 @main

我想在 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!")
      }
    }
  }
} …
Run Code Online (Sandbox Code Playgroud)

swift swiftui ios14 xcode12

7
推荐指数
3
解决办法
5999
查看次数

标签 统计

ios14 ×1

swift ×1

swiftui ×1

xcode12 ×1