为 ionic 5 代码构建 ios 版本时出现 defaultWebpagePreferences 错误

d3v*_*pro 2 cordova ionic-framework cordova-plugins wkwebviewconfiguration ionic5

我正在尝试为 ionic 5 应用程序构建一个 ios 版本,我在构建应用程序时在我的应用程序中收到此错误。我在互联网上寻找解决方案,但似乎没有任何效果

/Users/Prateek/ionicApps/muniFlores/platforms/ios/CordovaLib/Classes/Private/Plugins/CDVWebViewEngine/CDVWebViewEngine.m:141:27: error: property
      'defaultWebpagePreferences' not found on object of type 'WKWebViewConfiguration *'
            configuration.defaultWebpagePreferences.preferredContentMode = WKContentModeMobile;
                          ^
/Users/Prateek/ionicApps/muniFlores/platforms/ios/CordovaLib/Classes/Private/Plugins/CDVWebViewEngine/CDVWebViewEngine.m:141:76: error: use of undeclared
      identifier 'WKContentModeMobile'
            configuration.defaultWebpagePreferences.preferredContentMode = WKContentModeMobile;
                                                                           ^
/Users/Prateek/ionicApps/muniFlores/platforms/ios/CordovaLib/Classes/Private/Plugins/CDVWebViewEngine/CDVWebViewEngine.m:143:27: error: property
      'defaultWebpagePreferences' not found on object of type 'WKWebViewConfiguration *'
            configuration.defaultWebpagePreferences.preferredContentMode = WKContentModeDesktop;
                          ^
/Users/Prateek/ionicApps/muniFlores/platforms/ios/CordovaLib/Classes/Private/Plugins/CDVWebViewEngine/CDVWebViewEngine.m:143:76: error: use of undeclared
      identifier 'WKContentModeDesktop'
            configuration.defaultWebpagePreferences.preferredContentMode = WKContentModeDesktop;
Run Code Online (Sandbox Code Playgroud)

Nik*_*erz 5

您的 Xcode 版本可能是您的 Cordova iOS 平台不支持的版本。如果您降级您的cordova-ios平台版本,它应该可以工作。尽管如此,我强烈建议您尽可能更新您的 Xcode。

更改是在 version 中引入的6.1.0。在此处检查提交:https : //github.com/apache/cordova-ios/commit/440fc0fe01dabbccfd703ac7854fd24b0b88e1b5

这意味着使用6.0.0ios 平台的版本可能有效。安装:

cordova platform rm ios
cordova platform install ios@6.0.0
Run Code Online (Sandbox Code Playgroud)

但是这个版本还有其他问题在 Cordova-ios 的后续补丁版本中得到解决。