问题
I have a plain Cordova app and when I run it on iOS 14 beta the app gets stuck on the splash screen and there are few warnings/errors logged in XCode but I am not sure whether it is causing the problem.
I have created a blank Cordova app to test whether it works on iOS 14 and when I run it on the device the app worked as expected but when I set the app to use WKWebView instead of UIWebView the app got stuck on the splash screen.
I have added the below preferences to use the WKWebView in config.xml file.
<preference name="WKWebViewOnly" value="true" />
<feature name="CDVWKWebViewEngine">
<param name="ios-package" value="CDVWKWebViewEngine" />
</feature>
I have also added the cordova-plugin-wkwebview-engine but I do not know whether it helped me to set the WKWebView.
Below is the error I get in XCode:
2020-08-17 12:01:37.990216+0530 BankWindhoek[58947:1465531] nil host used in call to allowsAnyHTTPSCertificateForHost:
2020-08-17 12:01:37.991180+0530 BankWindhoek[58947:1465531] nil host used in call to allowsSpecificHTTPSCertificateForHost
But after getting this error the XCode prints the statement that it has loaded the index.html
2020-08-17 12:01:38.039671+0530 BankWindhoek[58947:1465275] Finished load of: file:///Users/user1/Library/Developer/CoreSimulator/Devices/88FDF8E3-EDCE-4BB6-95B3-29CA606DA2C5/data/Containers/Bundle/Application/6EE35C46-E78E-4E49-B836-17EBDE6CD664/test.app/www/index.html
But on the UI of the app, nothing renders properly and shows a blank white screen.
Configurations:
Cordova Version: 9.0.0
Cordova-ios: 5.1.1
Note: If I run the same app on iOS 13/iOS 13.1 it worked as expected.
回答1:
You should upgrade to Cordova 10 and then remove
<preference name="WKWebViewOnly" value="true" />
<feature name="CDVWKWebViewEngine">
<param name="ios-package" value="CDVWKWebViewEngine" />
</feature>
and remove
cordova-plugin-wkwebview-engine
Then
cordova plugin add @globules-io/cordova-plugin-ios-xhr
and setup the flags like you would for wkwebview-engine.
You also have to upgrade your splashscreen plugin for the new splashscreen image format. Read https://cordova.apache.org/news/2020/07/21/splashscreen-plugin-release.html
来源:https://stackoverflow.com/questions/63445822/cordova-app-stuck-on-splash-screen-on-ios-14-beta