apache / cordova-ios

Apache Cordova iOS
https://cordova.apache.org/
Apache License 2.0
2.15k stars 987 forks source link

iOS Simulator shows 'about:blank' when scheme/hostname preferences are set #1215

Open cellcrowd opened 2 years ago

cellcrowd commented 2 years ago

Bug Report

Problem

When adding

<preference name="scheme" value="app" />
<preference name="hostname" value="localhost" />

into the <platform name="ios"> section of config.xml, the iOS simulator shows "about:blank" page instead of "index.html" page

What is expected to happen?

App should display "index.html" page

What does actually happen?

App displays "about:blank" page

Information

This bug does not happen on real devices, only in the simulator

When running document.location = 'app://index.html' through the Safari debugger, the page loads. However, it fails to load CSS with error: Did not parse stylesheet at 'app://index.html/css/index.css' because non CSS MIME types are not allowed in strict mode.

Running document.location = 'app://localhost' does the same as above with error: Did not parse stylesheet at 'app://localhost/css/index.css' because non CSS MIME types are not allowed in strict mode.

Running document.location = 'app://' shows 'about:blank'

Running document.location = 'app://localhost/index.html' does not do anything (returns "app://localhost/index.html" = $1 in console)

Command or Code

Environment, Platform, Device

iOS Simulator on Mac OS Big Sur 11.6, Mac Mini (M1, 2020) 8GB

Version information

Cordova CLI 11.0.0 Cordova iOS 6.2.0

Checklist

cellcrowd commented 2 years ago

Confirmed working when starting the simulator from XCode instead of the CLI

jcesarmobile commented 2 years ago

There is a known issue on iOS simulator when running on M1 macs. If you say it works when you run from Xcode and not from the CLI, it's probably that Xcode is setting rosetta mode on the simulator, not sure if it would be possible to do the same from the CLI.

mcake8 commented 1 year ago

I got the very same issue, but even from the XCode it doesn't work for me Device: MacBook Pro (16-inch, 2021) M1 Pro 16 GB Cordova CLI 11.0.0 Cordova iOS 6.2.0

if I set the config like this

 <preference name="scheme" value="app" />
<preference name="hostname" value="www.my-awesome-site.com" />

App displays "about:blank" page, and the XCode console says something like this

2022-08-19 20:16:15.564214+0400 HelloWorld[42258:3653880] [db] Failed to initialize client context with error Error Domain=NSOSStatusErrorDomain Code=-10817 "(null)" UserInfo={_LSFunction=_LSSchemaConfigureForStore, ExpectedSimulatorHash={length = 32, bytes = 0xde692fe4 74cb27a9 46141ef2 d51b2967 ... 1bf15bf0 1946d147 }, _LSLine=405, WrongSimulatorHash={length = 32, bytes = 0xb5aceade 20f27303 c39ab815 65e94ec7 ... cd950a70 602e0a75 }} 2022-08-19 20:16:15.848182+0400 HelloWorld[42258:3653880] [Process] 0x7fdb00025c20 - [pageProxyID=11, webPageID=12, PID=42283] WebPageProxy::didFailProvisionalLoadForFrame: frameID=3, domain=WebKitErrorDomain, code=102 2022-08-19 20:16:15.849028+0400 HelloWorld[42258:3653880] Failed to load webpage with error: Frame load interrupted

It works well if I set it like so

 <preference name="hostname" value="localhost" />

I'm completely confused, I wasn't able to find clear documentation for those preferences. Tried to run the simulator with the Cordova CLI and the XCode both gave me the same result. Also before moving to the M1 chip everything was working well on the Intel chip with the first example name="scheme" value="app".

So the question is, should I use different config settings for the production and debug, or should I put it the way it works on the simulator? Or maybe I should not use the simulator for the ios on the M1 chip and just leave the config like it was working before on the Intel?