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

file:// protocol URL support #25

Open
TomasHubelbauer opened this issue May 25, 2023 · 1 comment
Open

file:// protocol URL support #25

TomasHubelbauer opened this issue May 25, 2023 · 1 comment

Comments

@TomasHubelbauer
Copy link

TomasHubelbauer commented May 25, 2023

Hi, I tried building off of latest master and found that the screensaver works well for web URLs but I couldn't get it to load a local file:// protocol URL. Is there any way to make it support this?

There are some solutions here: https://stackoverflow.com/q/49638653/2715716. They rely on adding the local file to the app's bundle though. I would like to avoid that.

Is this the only way or is there is some kind of a flag I can toggle on the WKWebView or a capability I can add to the app to allow it to access files not in the XCode project.

I tried this:

- (void)loadUrl
{
    [webView.configuration.preferences setValue:@"TRUE" forKey:@"allowFileAccessFromFileURLs"];
    NSURL *url = [NSURL fileURLWithPath:@"/Users/…/index.html"];
    [webView loadFileURL:url.absoluteURL allowingReadAccessToURL:url.URLByDeletingLastPathComponent];

    lastLoad = [[NSDate alloc] init];
    DebugLog(@"reloaded %@",[lastLoad description]);
}

But I only get a blank screen. I don't know how to check the logs since the screen saver cannot be run from XCode. I also tried appending file:// to the URL string to no avail.

@TomasHubelbauer
Copy link
Author

I looked around and it seems that in order to do this, there would need to be a separate launcher application for the screen saver or it would need to be ported to use the new .appex extension type of a thing. .saver bundles are now considered legacy in the macOS land. If .appex was used, one could configure its entitlements to add the capability to read local files, but .saver bundles cannot have their entitlements changed, they inherit the entitlements from legacyScreenSaver.appex which I am not sure what they are but the ability to read local files is not one of them, I've checked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant