Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: WASM MIME type error by specifying it in Info.plist template #1374

Merged
merged 2 commits into from
Mar 6, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 20 additions & 0 deletions templates/project/__PROJECT_NAME__/__PROJECT_NAME__-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,25 @@
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UTExportedTypeDeclarations</key>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious if this also works if you use UTImportedTypeDeclarations as the key

I don't think we want to declare all Cordova apps as owners of the WebAssembly file type by default, so UTExportedTypeDeclarations seems like it might be the wrong key to use. Even with that though, I think injecting this when needed using config-file in config.xml for your app is probably a better choice that unconditionally including this declaration in the template for all Cordova apps.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like your idea of using UTImportedTypeDeclarations key instead! I tested it and I can confirm that it works as well.

I understand there are differing views on whether loading WebAssembly code should be supported by default or only when needed.

I would argue for making this a default because I assume quite a few developers will be unaware of the problem until it suddenly occurs in their Testflight or release build. The cause is not easy to find, because the problem does not seem to occur in debug builds, which makes debugging difficult. This could be confusing and will cost time. At the same time, I don't see any downside how the UTImportedTypeDeclarations entry could cause problems.

Nevertheless, at least the documentation should point out the WASM loading error in release builds and explain how to fix it when needed using config-file in config.xml.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it's optimistic, but it would be great if we could have a script to detect if the code is using WASM or not, then warn users to enable usage of WASM in config.xml. But for now this could be enough to somehow easily enable WASM support in config.xml. Putting all those config lines in config.xml is not a minimal way to enable WASM. Maybe a boolean preference like EnableWASM makes sense.

<preference name="EnableWASM" value="true" />

<array>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.data</string>
</array>
<key>UTTypeDescription</key>
<string>WebAssembly</string>
<key>UTTypeIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<string>wasm</string>
<key>public.mime-type</key>
<string>application/wasm</string>
</dict>
</dict>
</array>
</dict>
</plist>