cordovaionic-frameworkcordova-pluginsionic5wkwebviewconfiguration

defaultWebpagePreferences error while building ios build for ionic 5 code


I am trying to build an ios build for ionic 5 app, i am getting this error in my app while building the app. I looked out for solutions on internet but nothing seems to work

/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;

Solution

  • Your Xcode version is probably a version not supported by your Cordova iOS platform. If you downgrade your cordova-ios platform version it should work. Nevertheless I strongly suggest updating your Xcode if possible.

    The change was introduced in version 6.1.0. Check the commit here: https://github.com/apache/cordova-ios/commit/440fc0fe01dabbccfd703ac7854fd24b0b88e1b5

    This means using version 6.0.0 of the ios platform probably works. To install:

    cordova platform rm ios
    cordova platform install ios@6.0.0
    

    But this version has other issues addressed in later patch versions of cordova-ios.