使用 Ionic react v 5.3.0 编写一个简单的应用程序,还没有插件
ionic build 后,Xcode 报告 swift build 错误:
Type 'UIStatusBarStyle' has no member 'darkContent' ios
这发生在 swift v 4.2 和 swift v 5,ios 部署目标 8、9、10 和 11
我尝试按照此处的说明删除和重新生成目录来解决node_modules
:ios
https: //ionicframework.com/docs/troubleshooting/native
仍然在 xcode 中看到带有构建时警告和 4 个 Swift 编译错误的问题。在 CapBridgeViewcontroller.swift
中发现了其中两个错误Type 'UIColor' has no member 'systemBackground'
Pods>Development Pods> Capacitor > Plugins
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
}
另外两个错误是:
Type 'UIStatusBarStyle' has no member 'darkContent'
在 statusBar.swift 中找到
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([:])
}
我期望的是我可以从 ionic cli 构建我的应用程序,而不必每次构建时都修改 swift 代码。我可以在我的 ionic 项目中添加一个设置来防止这个错误吗?