Home > Blockchain >  How to check am I using WKWebview instead of UIWebview in cordova app
How to check am I using WKWebview instead of UIWebview in cordova app

Time:05-24

My app had a display problem when I used Adobe PhoneGap Build. Somehow I solved it via migrating UIWebveiw to WKwebview. Since PhoneGap Build ends its service, I am trying to use cordova command to build my app and same problem occurs.

I tried several config.xml settings and also tried setting Xcode's "Build Settings" > "User-Defined" > "WK_WEB_VIEW_ONLY" into 1. but still had this problem.

I am not sure whether I am using WKwebview or not. And If not, what's wrong with my setting? And If yes, what should I try next to bebug?

Here's how I build my app:

  1. I create my project via cordova create <Folder> <BundleID> <MyProjectName>
  2. put my website into "www" folder
  3. then cordova platform add ios (I am using [email protected])
  4. click my .xcodeproj and click build button (the triangle button like "play") in Xcode.

Here's my config.xml:

<?xml version='1.0' encoding='utf-8'?>
<widget id="com.test.test" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <name>test</name>
    <description>Sample Apache Cordova App</description>
    <author email="[email protected]" href="https://cordova.apache.org">
        Apache Cordova Team
    </author>
    <content src="index.html" />
    <allow-intent href="http://*/*" />
    <allow-intent href="https://*/*" />
    <preference name="WKWebViewOnly" value="true" />

    <feature name="CDVWKWebViewEngine">
        <param name="ios-package" value="CDVWKWebViewEngine" />
    </feature>

    <preference name="CordovaWebViewEngine" value="CDVWKWebViewEngine" />
</widget>

my files image

Here's my main.m , I am not familiar with swift but it seems like using UIWebveiw instead of WKwebview in my app.

#import <UIKit/UIKit.h>

int main(int argc, char* argv[])
{
    @autoreleasepool {
        int retVal = UIApplicationMain(argc, argv, nil, @"AppDelegate");
        return retVal;
    }
}

The problem is haunting me for a long time and I can't figure out why and how. Thank you in advanced.

CodePudding user response:

If you have upgraded to Cordova iOS 6 , there is no need to specify WKWebView anymore as it is the WebView by default.

<preference name="WKWebViewOnly" value="true" />
<feature name="CDVWKWebViewEngine">
    <param name="ios-package" value="CDVWKWebViewEngine" />
</feature>
<preference name="CordovaWebViewEngine" value="CDVWKWebViewEngine" />

These are obsolete with Cordova

See this and this

  • Related