Please try this.
htmlFile is a xojo.io.folderitem pointing to the html file in SpecialFolder.Documents
[code]Declare Function NSClassFromString Lib “Foundation.framework” (clsName As CFStringRef) As ptr
Declare Function URLWithString Lib “Foundation.framework” Selector “URLWithString:” ( id As Ptr, URLString As CFStringRef ) As Ptr
Declare sub loadFileURL lib “UIKit.framework” selector “loadFileURL:allowingReadAccessToURL:” (obj as ptr, url as ptr, readAccessURL as ptr)
Dim nsURL As Ptr = URLWithString(NSClassFromString(“NSURL”), htmlFile.URLPath)
Dim readURL As Ptr = URLWithString(NSClassFromString(“NSURL”), htmlFile.parent.URLPath)
loadFileURL(htmlPresentation.Handle, nsURL, readURL)[/code]
=== EDIT ===
Explanation from apple forums thread
[quote]The most important thing in my code is not the way how to get url or path, but using the method loadFileURL(_:allowingReadAccessTo:)
.
In fact, the core part of WKWebView runs in a different process (or processes, maybe), which does not have read access to an app’s Documents folder where it it Sandboxed.
In simulators, some part of macOS file system is simulated as an iOS devices file system, but the protection of Sandboxing is sort of loose and the process of WKWebView can access the Documents directory of the app.
allowingReadAccessTo:
allows temprary read access to the WKWevView process (I do not know the detail, just that it works), so even in strictly Sandboxed environment, loadFileURL(_:allowingReadAccessTo:)
would work as expected.[/quote]