WKWebView behaves differently between the Simulator and a device.

Number:rdar://47312413 Date Originated:16-Jan-2019 11:58 AM
Status:Closed Resolved:Duplicate
Product:iOS + SDK Product Version:iOS 12.1
Classification:Serious Bug Reproducible:Always
On an iPhone or iPad simulator, you can do a whole bunch of things which are not possible on a device: 

- You can load documents using a `URLRequest` with a file URL passed into `load(_)`. 
- When loading using the `loadFileURL(_, allowingReadAccessTo:)` method to load a file from a URL,  you can pass in any URL to the `allowingReadAccessTo` parameter and loading will work, albeit occasionally with errors printed to the console. The files still load correctly though.

Steps to Reproduce:
1. Build app using simulator which loads things using WKWebView from the user-domain-masked Documents and Caches directories using `URLRequest`.
2. Receive bug reports that nothing is loading on device.
3. Fix issue on iPhone by using `loadFileURL(_, allowingReadAccessTo:)`, passing in the file being loaded. 
4. Receive further bug report that only the first PDF is loading on iPad. 
5. Investigate, discover bits in “Description” and realize you have to recreate the web view every time if you want to load from either Caches or Documents.
6. Locate stiff drink

Expected Results:
WKWebView APIs should work (or, if intended, not work) consistently across simulator and device.

Actual Results:
See “Steps to repro”; heavy drinking.

iOS 12.1

iOS 12.1, Xcode 10.1 10B61

It's very frustrating to have this work very differently on device and on the Simulator, because things break in flagrantly obvious ways for users in a way that's not predictable or testable from the Sim.

Yes, yes, yes: Test on device. But this is a big enough functionality change that, at least to me, does not seem hardware dependent, that it seems really incongruous to have it work fine on the Sim and die on device.


Got an email this morning that it was closed as a dupe of rdar://6451211 - will try to check it out in future betas of Xcode 10.2, I suppose.

By designatednerd at Feb. 8, 2019, 8:54 a.m. (reply...)

Attached this project to the radar as well: https://github.com/designatednerd/FileARadar/tree/master/WKWebViewShenanigans

By designatednerd at Jan. 16, 2019, 11 a.m. (reply...)

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!