我用ionic 4和cordova构建了一个应用程序。在android上,该应用程序运行像一个咒语,但在iOS上,我遇到了一些奇怪的问题……就像其他问题一样(Ionic IOS app NSURLConnection error 1100,ionic 4 app shows white screen on ios with error code 1100)。 该应用程序离子化版本运行良好,没有任何错误,并且仅对未使用的导入发出了一些警告。而且,xcode的构建是快速而成功的。但是,当应用程序在真实设备或模拟器上运行时,我只会出现空白的空白屏幕。在控制台中,我通过其他调试得到了这一点:
我发现提到了一些类似的问题,并且还添加了环境变量(CFNETWORK_DIAGNOSTICS = 1
)用于高级网络日志记录,以在控制台(整个文件:https://pastebin.com/yecJ5Vzy)中获得更多信息(或在此处找到一些摘要): / p>
2019-05-03 10:59:49.788736+0200 MyNiceApp[3426:1312031] CFNetwork Diagnostics [1:1] 10:59:49.787 {
DiskCookieStorage Construction: Binary{ Disk Cookies: { /private/var/mobile/Containers/Data/Application/23CCB045-0976-4DD0-A19B-0BD8CB6825FD/Library/Cookies/Cookies.binarycookies, <0 cookies in 0 domains> clean not writing } }
Accessing: <CFURL 0x282db3c60 [0x1bda5d610]>{string = file:///private/var/mobile/Containers/Data/Application/13371337-0976-4DD0-A19B-0BD8CXYZAS/Library/Cookies/Cookies.binarycookies, encoding = 13371337, base = (null)}
Path: /private/var/mobile/Containers/Data/Application/13371337-0976-4DD0-A19B-0BD8CXYZAS/Library/Cookies/Cookies.binarycookies
Read from disk: <0 cookies in 0 domains>
Dirty: NO
Writing: NO
Policy: 0
} [1:1]
2019-05-03 10:59:49.788845+0200 MyNiceApp[3426:1312031] CFNetwork Diagnostics [1:2] 10:59:49.788 {
DiskCookieStorage Journaling On: Binary{ Disk Cookies: { /private/var/mobile/Containers/Data/Application/13371337-0976-4DD0-A19B-0BD8CXYZAS/Library/Cookies/Cookies.binarycookies, <0 cookies in 0 domains> clean not writing } }
File: <CFURL 0x282db3c60 [0x1bda5d610]>{string = file:///private/var/mobile/Containers/Data/Application/13371337-0976-4DD0-A19B-0BD8CXYZAS/Library/Cookies/Cookies.binarycookies, encoding = 13371337, base = (null)}
} [1:2]
2019-05-03 10:59:49.879254+0200 MyNiceApp[3426:1312031] Apache Cordova native platform version 5.0.0 is starting.
2019-05-03 10:59:49.879772+0200 MyNiceApp[3426:1312031] Multi-tasking -> Device: YES, App: YES
2019-05-03 10:59:49.901704+0200 MyNiceApp[3426:1312031] Using UIWebView
2019-05-03 10:59:49.904145+0200 MyNiceApp[3426:1312031] [CDVTimer][console] 0.041008ms
2019-05-03 10:59:49.904228+0200 MyNiceApp[3426:1312031] [CDVTimer][handleopenurl] 0.049949ms
2019-05-03 10:59:49.905236+0200 MyNiceApp[3426:1312031] Unlimited access to network resources
2019-05-03 10:59:49.905271+0200 MyNiceApp[3426:1312031] [CDVTimer][intentandnavigationfilter] 1.001954ms
2019-05-03 10:59:49.905338+0200 MyNiceApp[3426:1312031] [CDVTimer][gesturehandler] 0.050068ms
2019-05-03 10:59:49.905379+0200 MyNiceApp[3426:1312031] [CDVTimer][backgroundfetch] 0.025034ms
2019-05-03 10:59:49.905397+0200 MyNiceApp[3426:1312031] [CDVTimer][TotalPluginStartup] 1.327991ms
2019-05-03 10:59:50.139954+0200 MyNiceApp[3426:1312031] Resetting plugins due to page load.
2019-05-03 10:59:50.158278+0200 MyNiceApp[3426:1312115] CFNetwork Diagnostics [1:3] 10:59:50.158 {
LoaderWhatToDo: (null)
Request: <CFURL 0x282db7c00 [0x1bda5d610]>{string = file:///var/containers/Bundle/Application/13371337-0976-4DD0-A19B-0BD8CXYZAS/MyNiceApp.app/www/index.html, encoding = 13371337, base = (null)}
CachePolicy: 0
WhatToDo: originload
CreateToNow: 0.00069s
} [1:3]
2019-05-03 10:59:50.161705+0200 MyNiceApp[3426:1312031] Failed to load webpage with error: The operation couldn’t be completed. (NSURLErrorDomain error -999.)
2019-05-03 10:59:50.162212+0200 MyNiceApp[3426:1312031] Resetting plugins due to page load.
2019-05-03 10:59:50.162894+0200 MyNiceApp[3426:1312115] CFNetwork Diagnostics [1:4] 10:59:50.162 {
LoaderWhatToDo: (null)
Request: <CFURL 0x282d94060 [0x1bda5d610]>{string = file:///var/containers/Bundle/Application/13371337-0976-4DD0-A19B-0BD8CXYZAS/MyNiceApp.app/www/index.html, encoding = 13371337, base = (null)}
CachePolicy: 0
WhatToDo: originload
CreateToNow: 0.00030s
} [1:4]
稍后在控制台日志中:
2019-05-03 10:59:50.278000+0200 MyNiceApp[3426:1312114] NSURLConnection finished with error - code -1100
2019-05-03 10:59:50.278024+0200 MyNiceApp[3426:1312114] NSURLConnection finished with error - code -1100
该应用似乎无法加载自己的文件。.由于错误-1100表示NSURLErrorFileDoesNotExist
答案 0 :(得分:0)
遇到了同样的问题,经过一番苦苦挣扎和研发,这才对我有用。
似乎相对路径是由IOS占用的,因此在您的src-> index.html中,请更改此设置 基本href =“ /” 至 基本href =“ ./”(/开头的点号)
这将加载所有相关的js文件(cordova.js,polyfill.js等)
1100错误是由于绝对路径而找不到文件。
答案 1 :(得分:0)
在研究了很多东西之后,我的解决方案是执行以下命令:
ionic cordova plugin add cordova-plugin-ionic-webview --save