我一直在从事javascript项目,客户端要求将其发布到AppStore。我们选择与PhoneGap合作,因为它为我们做了很多工作,并且结果令人满意。但是,与仅在Safari上运行的应用程序相比,某些Apple设备上的性能很差。
在对UIWebView以及如何弃用UIWebView进行了一些阅读之后,我决定尝试一下WKWebView,希望性能至少会好一点。
我成功安装了 cordova-plugin-wkwebview-engine ,然后使我想到了很多人遇到的XHR问题。但是我通过这篇帖子https://stackoverflow.com/a/42953116/10551718
找到了解决方案我遇到的问题是,当我尝试复制这位先生所做的事情时,我在PhoneGap版本中遇到有关 cordova-plugin-wkwebview-engine-localhost 的错误,说不能克隆git存储库。
Build Date: 2018-10-24 04:20:25 -0700
--------------------------------------------------------------------------------
PLUGIN OUTPUT
--------------------------------------------------------------------------------
Fetching plugin "cordova-plugin-splashscreen" via npm
Installing "cordova-plugin-splashscreen" at "5.0.2" for ios
Fetching plugin "cordova-plugin-wkwebview-engine" via npm
Installing "cordova-plugin-wkwebview-engine" at "1.1.4" for ios
"plugman-151 install --platform ios --project /project --plugin https://github.com/apache/cordova-plugins.git#wkwebview-engine-localhost --nohooks=.": Fetching plugin "https://github.com/apache/cordova-plugins.git" via git clone
Using shallow clone
Repository "https://github.com/apache/cordova-plugins.git" checked out to git ref "wkwebview-engine-localhost" at "a3cc931".
Installing "cordova-labs-wkwebview-engine-localhost" at "0.5.1" for ios
Fetching plugin "git+https://github.com/apache/cordova-plugins.git" via git clone
Cloning full repository
Failed to install 'cordova-labs-wkwebview-engine-localhost': Error
at /.nvm/versions/node/v8.1.4/lib/node_modules/pgb-plugman-151/node_modules/pgb-cordova-lib/src/plugman/fetch.js:100:37
at _rejected (/.nvm/versions/node/v8.1.4/lib/node_modules/pgb-plugman-151/node_modules/cordova-common/node_modules/q/q.js:864:24)
at /.nvm/versions/node/v8.1.4/lib/node_modules/pgb-plugman-151/node_modules/cordova-common/node_modules/q/q.js:890:30
at Promise.when (/.nvm/versions/node/v8.1.4/lib/node_modules/pgb-plugman-151/node_modules/cordova-common/node_modules/q/q.js:1142:31)
at Promise.promise.promiseDispatch (/.nvm/versions/node/v8.1.4/lib/node_modules/pgb-plugman-151/node_modules/cordova-common/node_modules/q/q.js:808:41)
at /.nvm/versions/node/v8.1.4/lib/node_modules/pgb-plugman-151/node_modules/cordova-common/node_modules/q/q.js:624:44
at runSingle (/.nvm/versions/node/v8.1.4/lib/node_modules/pgb-plugman-151/node_modules/cordova-common/node_modules/q/q.js:137:13)
at flush (/.nvm/versions/node/v8.1.4/lib/node_modules/pgb-plugman-151/node_modules/cordova-common/node_modules/q/q.js:125:13)
at _combinedTickCallback (internal/process/next_tick.js:95:7)
at process._tickCallback (internal/process/next_tick.js:161:9)
Failed to fetch plugin git+https://github.com/apache/cordova-plugins.git via git.
Either there is a connection problems, or plugin spec is incorrect:
Error: git: Command failed with exit code 128 Error output:
Cloning into '/var/folders/lt/xxbrk07x45bdj1fl3wjgf8yc0000gn/T/git/1540380025411'...
fatal: Unable to find remote helper for 'git+https'
我在我的配置文件中...
<plugin name="cordova-plugin-splashscreen" source="npm" />
<plugin name="cordova-plugin-wkwebview-engine" source="npm" />
<plugin name="cordova-plugin-wkwebview-engine-localhost" spec="https://github.com/apache/cordova-plugins.git#wkwebview-engine-localhost" />
<content src="http://localhost" />
<feature name="CDVWKWebViewEngine">
<param name="ios-package" value="CDVWKWebViewEngine" />
</feature>
<preference name="CordovaWebViewEngine" value="CDVWKWebViewEngine" />
任何帮助将不胜感激!
答案 0 :(得分:0)
我最终找到了一个替代插件-https://github.com/ionic-team/cordova-plugin-ionic-webview
此安装没有问题,并正确强制了 WKWebView ,从而大大提高了性能!