bug: iOS 14.5 apps not loading global Ionic Styles in emulator
Bug Report
Capacitor Version
Latest Dependencies:
@capacitor/cli: 3.0.2
@capacitor/core: 3.0.2
@capacitor/android: 3.0.2
@capacitor/ios: 3.0.2
Installed Dependencies:
@capacitor/android: not installed
@capacitor/cli: 3.0.2
@capacitor/ios: 3.0.2
@capacitor/core: 3.0.2
Platform(s)
iOS 14.5
Current Behavior
App is not loading Ionic Styles. Inspecting with Safari I can see the styles.css file is empty. EDIT: Inspecting from Safari in Simulator I get this error: Did not parse stylesheet at 'capacitor://localhost/styles.css' because non CSS MIME types are not allowed in strict mode.
Expected Behavior
App styling correctly
Code Reproduction
Clone the repo: https://github.com/mrussmup/stylesbugios145
run ionic capacitor build ios Run the app in a iOS 14.5 Simulator
Other Technical Details
npm --version output:
6.14.10
node --version output:
14.15.4
pod --version output (iOS issues only):
1.10.1
Additional Context
Developing on a Mac Air M1. Opening XCode with Rosetta
This issue may need more information before it can be addressed. In particular, it will need a reliable Code Reproduction that demonstrates the issue.
Please see the Contributing Guide for how to create a Code Reproduction.
Thanks! Ionitron 💙
Bug Report
Capacitor Version
Latest Dependencies:
@capacitor/cli: 3.0.2
@capacitor/core: 3.0.2
@capacitor/android: 3.0.2
@capacitor/ios: 3.0.2
Installed Dependencies:
@capacitor/android: not installed
@capacitor/cli: 3.0.2
@capacitor/ios: 3.0.2
@capacitor/core: 3.0.2
Platform(s)
iOS 14.5
Current Behavior
App is not loading Ionic Styles. Inspecting with Safari I can see the styles.css file is empty. EDIT: Inspecting from Safari in Simulator I get this error: Did not parse stylesheet at 'capacitor://localhost/styles.css' because non CSS MIME types are not allowed in strict mode.
Expected Behavior
App styling correctly
Code Reproduction
Clone the repo: https://github.com/mrussmup/stylesbugios145
run ionic capacitor build ios Run the app in a iOS 14.5 Simulator
Other Technical Details
npm --version output:
6.14.10
node --version output:
14.15.4
pod --version output (iOS issues only):
1.10.1
Additional Context
Developing on a Mac Air M1. Opening XCode with Rosetta
I can't reproduce, but I don't have M1 mac, it's probably related to that.
Does your www/styles.css have content? or is it empty too?
And the ios/App/App/public/styles.css?
Did you see any problems on the terminal when you ran npx cap add ios or npx cap update ios or npx cap sync ios?
Both files have content. The only problem is that on Safari Inspector the brwoser expects a mime type text/css but the Ionic app serves that file as octet/stream.
I haven't found any problems with all of that commands.
UPDATE
No problems for me too on an older Intel Macbook Air.
On M1 emulators UTTypeCreatePreferredIdentifierForTag always returns nil.
https://github.com/ionic-team/capacitor/blob/b893a57aaaf3a16e13db9c33037a12f1a5ac92e0/ios/Capacitor/Capacitor/WebViewAssetHandler.swift#L64

Same problem with cordova-plugin-ionic-webview in Objective-C. A workaround is to explicit mapping file extension to mime. https://github.com/qrdp/cordova-plugin-ionic-webview/commit/0c2e2731a6fa655a03ebb13492acb6990af0da7d#diff-af7cc7d07bec4a8ea0e271d11092d77a789646fdfd5ce2cbdf6307b4d8198b5aR74
@qrdp Still not working after installing your fork. How can I fix?
@mrussmup My fork of cordova-plugin-ionic-webview is just an example (for cordova project).
I think you can try to fork Capacitor and do something like this https://github.com/qrdp/capacitor/commit/228d591b9bdc13a9513e4d7b986855e8dcb5d845
Unfortunately, I can not run the code and check it now
@qrdp I'm running a Cordova project. So I have to map in that long variable of types the correct type that the app receives? Sorry about those questions but I'm absolutely not familiar with Objective-C.
@mrussmup Check out the demo project https://github.com/qrdp/corodova-m-1-demo. It works fine on my MacBook M1.
https://github.com/qrdp/corodova-m-1-demo/blob/20153e4da693ed3350460361e9c6a52d2b05c70f/package.json#L54
After changing the version, it is better to clear the platform and plugin directories and rebuild project.
Now is working fine. Thank you
I am having same issue. On Mac with M1 because some of the frameworks don't support M1, I had to switch XCode to Rosetta.
When I am doing that, project is missing all css when built.
It works fine in non Rosetta mode.
I have cleared all project build folders etc. no joy
I've encountered this issue days ago and turning off the "Open using Rosetta" solved my issue wherein the simulator does not render properly my app and the Safari console shows error like this:

I turned it off by going to Finder > Right click "Xcode.app" > Get Info > Untick "Open using Rosetta"

Additional Context
Developing on a MacBook Air M1 with macOS Big Sur 11.2.3. Opening XCode with Rosetta
Other Technical Details
npm --version: 6.14.12node --version: 14.16.1pod --version: 1.11.0
closing as know apple bug, if you face the issue, use the workaround described on the last message
Rosetta was already off for me (M1 Max, XCode 13). Switching on/off Rosetta had no effect. I was able to workaround by modifying my index.html to include this instead of the main.css reference. A bit wonky - I'd rather capacitor serve up with correct MIME type, but am not ready to upgrade the app, so maybe this is acceptable workaround.
<script>
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.head.innerHTML = document.head.innerHTML + '<style type="text/css">' + this.responseText; + '</style>';
}
};
xhttp.open("GET", "build/main.css", true);
xhttp.send();
</script>
Still having the issue, turning off the "Open using Rosetta" didn't fixed it for me.
I am facing the same issue. Did not parse stylesheet at 'capacitor://localhost/static/css/4.b11a87a6.chunk.css' because non CSS MIME types are not allowed in strict mode.
node - 12.14.1
@capacitor/cli - 3.2.5
@capacitor/core - 3.2.5
@capacitor/ios - 3.3.4

The workaround does not work for me as well. Not using Rosetta, still getting: [Error] Did not parse stylesheet at 'capacitor://localhost/css/chunk-vendors.c95d1953.css' because non CSS MIME types are not allowed in strict mode. [Error] Did not parse stylesheet at 'capacitor://localhost/css/app.d6baf572.css' because non CSS MIME types are not allowed in strict mode.
I'm getting the same error when I try to run an app using yarn capacitor run ios but the app loads fine when I open the project in Xcode and run it from there.
Same issue when I run ionic cap run ios. When I run ionic cap build ios and run it through xcode it works fine.