如何防止 'UIColor' 没有成员 'systemBackground' 和 'UIStatusBarStyle' 在 ios 的 ionic/react v5 中没有成员 'dar



使用Ionic react v 5.3.0 编写一个简单的应用程序,还没有插件

ionic构建后,Xcode报告swift构建错误:Type 'UIStatusBarStyle' has no member 'darkContent' ios这种情况发生在swift v4.2和swift v5、ios部署目标8、9、10和11 上

我试图通过按照此处的说明删除和重新生成node_modulesios目录来解决问题:https://ionicframework.com/docs/troubleshooting/native

仍然在xcode中看到构建时警告和4个Swift编译错误的问题
其中两个错误是Pods>Development Pods> Capacitor > Plugins的CapBridgeViewcontroller.swift中发现的Type 'UIColor' has no member 'systemBackground'

if let backgroundColor = (bridge!.config.getValue("ios.backgroundColor") as? String) ?? (bridge!.config.getValue("backgroundColor") as? String) {
webView?.backgroundColor = UIColor(fromHex: backgroundColor)
webView?.scrollView.backgroundColor = UIColor(fromHex: backgroundColor)
} else if #available(iOS 13, *) {
// Use the system background colors if background is not set by user
webView?.backgroundColor = UIColor.systemBackground
webView?.scrollView.backgroundColor = UIColor.systemBackground
}

另外两个错误是:在statusBar.swift 中找到Type 'UIStatusBarStyle' has no member 'darkContent'

public func setStatusBarDefaults() {
if let plist = Bundle.main.infoDictionary {
if let statusBarHidden = plist["UIStatusBarHidden"] as? Bool {
if (statusBarHidden) {
self.isStatusBarVisible = false
}
}
if let statusBarStyle = plist["UIStatusBarStyle"] as? String {
if (statusBarStyle == "UIStatusBarStyleDarkContent") {
if #available(iOS 13.0, *) {
self.statusBarStyle = .darkContent
} else {
self.statusBarStyle = .default
}
} else if (statusBarStyle != "UIStatusBarStyleDefault") {
self.statusBarStyle = .lightContent
}
}
}
}

@objc func setStyle(_ call: CAPPluginCall) {
let options = call.options!
if let style = options["style"] as? String {
if style == "DARK" {
bridge.setStatusBarStyle(.lightContent)
} else if style == "LIGHT" {
if #available(iOS 13.0, *) {
bridge.setStatusBarStyle(.darkContent)
} else {
bridge.setStatusBarStyle(.default)
}
}
}

call.success([:])
}

我所期望的是,我可以从ion-cli构建我的应用程序,而不必每次构建时都修改swift代码。我可以在我的离子项目中添加一个设置来防止这个错误吗?

电容器需要Xcode 11来构建

https://capacitorjs.com/docs/getting-started/dependencies#ios-开发

上面的答案是:https://github.com/ionic-team/capacitor/issues/3338

最新更新