问题:
新建工程,选择最低支持iOS13报错:
'main()' is only available in iOS 14.0 or newer
'Scene' is only available in iOS 14.0 or newer
'WindowGroup' is only available in iOS 14.0 or newer
解决:
注释掉上面代码,重新创建一个AppDelegate作为入口:
import Foundation
import SwiftUI
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// 创建一个UIHostingController来托管你的ContentView
let contentView = ContentView()
// 设置window
let window = UIWindow(frame: UIScreen.main.bounds)
window.backgroundColor = .white
window.rootViewController = UIHostingController(rootView: contentView)
self.window = window
window.makeKeyAndVisible()
return true
}
}
info.plist中移除Application Scene Manifest
然后,重新运行就没问题了