Skip to content
This repository has been archived by the owner on Nov 7, 2018. It is now read-only.

Cordova WKWebVIew plugin does not work on simulator #177

Open
stripathix opened this issue Sep 11, 2017 · 17 comments
Open

Cordova WKWebVIew plugin does not work on simulator #177

stripathix opened this issue Sep 11, 2017 · 17 comments

Comments

@stripathix
Copy link

Created a new project using Cordova commands:

cordova create testapp
Then added following lines in config.xml to install cordova-plugin-wkwebview-engine:

<allow-navigation href="http://localhost:8080/*" />
<feature name="CDVWKWebViewEngine">
    <param name="ios-package" value="CDVWKWebViewEngine" />
</feature>
<preference name="CordovaWebViewEngine" value="CDVWKWebViewEngine" />
<engine name="ios" spec="^4.4.0" />
<plugin name="cordova-plugin-whitelist" spec="^1.3.2" />
<plugin name="cordova-plugin-wkwebview-engine" spec="git+https://github.com/driftyco/cordova-plugin-wkwebview-engine.git" />

Then Executed:

cordova platform add ios
cordova build ios

Now if I run this application on simulator then I get this screen:
ktntm

*Note: This works on real devices but on the simulator it always fails. No Idea what's going on.

Ref: https://github.com/ionic-team/cordova-plugin-wkwebview-engine

cordova: 7.0.1 cordova-ios: 4.4.0

@troyanskiy
Copy link

You should execute:

ionic cordova platform add ios
ionic cordova build ios

@mlynch
Copy link

mlynch commented Sep 20, 2017

Works fine on xcode 9/ios 11 simulators. Closing as can't reproduce

@mlynch mlynch closed this as completed Sep 20, 2017
@mlynch
Copy link

mlynch commented Sep 20, 2017

Yea on second glance it just looks like the build didn't happen so www/index.html wasn't created

@stripathix
Copy link
Author

@mlynch I am not able to run the app on the simulator. Using xCode9 and iOS11. It showed build succeeded :-( .

screen shot 2017-09-22 at 5 03 18 pm

screen shot 2017-09-22 at 5 03 32 pm

@troyanskiy
Copy link

@stripathix what exact command did you execute to build?

@stripathix
Copy link
Author

I am using:

cordova platform add ios
cordova build ios

Because my project is Cordova directory. Whenever I run ionic cordova build ios command I get error [ERROR] Sorry! ionic cordova build can only be run in an Ionic project directory.

screen shot 2017-09-22 at 5 20 15 pm

@troyanskiy
Copy link

So you can't use the plugin cordova-plugin-wkwebview-engine from Ionic-team.
There are 2 options for you.

  1. Switch you project to ionic project
  2. Use the plugin from apache https://github.com/apache/cordova-plugin-wkwebview-engine

@troyanskiy
Copy link

By executing just cordova build ios it just copies files from www folder to the platform and adding cordova.js + plugin js files.
And if you do ionic cordova build ios ionic compiles everything from src to www and then executes cordova build ios

@stripathix
Copy link
Author

But still, don't understand why it works on a real device but not on simulator.

Is there any difference in WkWebview plugin from ionic team and plugin by apache? Will it affect performance wise?

Will it be the big task to convert Cordova project directory to ionic directory?

@troyanskiy
Copy link

troyanskiy commented Sep 22, 2017

Is there any difference in WkWebview plugin from ionic team and plugin by apache? Will it affect performance wise?

No difference in performance

Will it be the big task to convert Cordova project directory to ionic directory?

Depends on your project

I think its easier to switch to the plugin from apache.

@stripathix
Copy link
Author

thanks @troyanskiy I will work on that and get back if face any issue.

@mlynch
Copy link

mlynch commented Sep 22, 2017

This should work, are you sure there's a www/index.html?

@stripathix
Copy link
Author

Yes, there is an index.html file once build is completed platforms/ios/www/index.html

screen shot 2017-09-22 at 6 20 10 pm

screen shot 2017-09-22 at 6 20 22 pm

@stripathix
Copy link
Author

Also, I can confirm this was working with the following environment:

a) Xcode 8.x
b) iOS 10.x
c) Plugin version: git+https://github.com/driftyco/cordova-plugin-wkwebview-engine.git#8409dbb

Now when I have updated to Xcode 9 and using the latest version of the plugin it's breaking in the simulator.

@manucorporat
Copy link

I can't reproduce this issue. Can you try:

rm -rf plaftorms
rm -rf plugins
ionic cordova build ios

?

@manucorporat manucorporat reopened this Sep 22, 2017
@kgeoir
Copy link

kgeoir commented Sep 26, 2017

Hello,
I am using Xcode 9 and IOS11, when I plug the wkwebview plugin, the browser is enable to load index.html.
screen shot 2017-09-26 at 9 50 54 am
I did rm -rf platform and plugin then build and still breaking. On my side it breaks on Xcode simulator and device BUT works perfectly when launching with cordova!
Any hint?

@stripathix
Copy link
Author

Finally, I found the reason for this. I think its the PORT localhost:8080 on which application is served inside WkWebView.

I am having a docker node container running, listening on 8080. So if I stop my docker container then application starts working on the simulator.

Is there any way to handle this situation. Like if we can change the PORT# for WkWebView?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants