NativeScript:
in webview works on iOS emulator, fails on iOS device
Environment
Provide version numbers for the following components (information can be retrieved by running tns info
in your project folder or by inspecting the package.json
of the project):
✔ Component nativescript has 4.2.4 version and is up to date.
✔ Component tns-core-modules has 4.2.1 version and is up to date.
✔ Component tns-android has 4.2.0 version and is up to date.
✔ Component tns-ios has 4.2.0 version and is up to date.
- Plugin(s): none
Describe the bug A simple webview with an image in a local folder is not loaded on an iOS device, but is loaded on an iOS simulator and on Android devices and simulator.
To Reproduce
Create a webview, include an tag and set the src= property to a local folder, i.e,
<img src="./marker_r.png" >
An external image will display properly on an iOS device, a local image will not.
Expected behavior Image is shown as it is on Android and an iOS simulator
Sample project https://play.nativescript.org/?template=play-js&id=2Jslpt&v=7 (Note that playground project does not include image file in local folder, but does show what attempts have failed)
Additional context This appears to be identical to https://github.com/NativeScript/NativeScript/issues/4443 but yet the problem persists with the latest NativeScript code.
Also posted at https://stackoverflow.com/questions/52712839/img-in-webview-works-on-ios-emulator-fails-on-ios-device
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 1
- Comments: 24 (3 by maintainers)
Commits related to this issue
- fix(ios-webview): loading of local-file dependency Fixes loading of html dependencies when loading a local file to web view. I've just implemented the code changes in the patch provided by @gregor... — committed to imerljak/NativeScript by imerljak 5 years ago
- fix(ios-webview): loading of local-file dependency (#6947) Fixes loading of html dependencies when loading a local file to web view. I've just implemented the code changes in the patch provided by... — committed to NativeScript/NativeScript by imerljak 5 years ago
- Add advice to ensure copying of src files to app Added advice -- the of CopyWebpackPlugin globs -- to mitigate errors in loading local src files because they were not copied to from the source code a... — committed to celsobessa/nativescript-sdk-examples-js by deleted user 4 years ago
- Add advice to ensure copying of src files to app (#184) Added advice -- the of CopyWebpackPlugin globs -- to mitigate errors in loading local src files because they were not copied to from the source... — committed to NativeScript/nativescript-sdk-examples-js by deleted user 3 years ago
Hi, I have made patch for this issue. You can apply this by this command
patch -p0 -l -f -i repair_ios_web_view.patch
file must be placed in root folder of project. repair_ios_web_view.zipI have a similar problem, when I’m loading html file contents load correctly(html code) but assets like a photo javascript and css doesn’t load. I try load assets from different paths in src attribute, eg.
but nothing works.
exampleApp.zip
I was able to get help on from @rigor789 on slack. I needed add my html paths to the copy plugin in webpack config.
new CopyWebpackPlugin([ { from: { glob: “fonts/" } }, { from: { glob: “www/*.html” } }, { from: { glob: "/.+(jpg|png)" } }, { from: { glob: "assets/**/” } }, ], { ignore: [
${relative(appPath, appResourcesFullPath)}/**
] }), new n This worked for me for loading files from the /app/www/ folder of my application.See Manoj’s response at https://stackoverflow.com/questions/52712839/img-in-webview-works-on-ios-emulator-fails-on-ios-device/52748358#52748358 - this is still looking like a {N} bug, methinks.