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

Change the way the final PWA app is formed on macOS #131

Closed
dakuzmin69 opened this issue Feb 16, 2022 · 2 comments
Closed

Change the way the final PWA app is formed on macOS #131

dakuzmin69 opened this issue Feb 16, 2022 · 2 comments
Labels
enhancement New feature or request
Milestone

Comments

@dakuzmin69
Copy link

Problem Description

AdGuard can't filter PWA due to the way PWAsForFirefox generates the executable for the PWA application.

Proposed Solution

The most preferred way is to replace the script with a real executable binary file.
This is a simple example source code for an executable.

import Foundation

let exePath = ProcessInfo.processInfo.environment["exePath"]!
let pwaId = ProcessInfo.processInfo.environment["pwaId"]!

let task = Process()
task.launchPath = exePath
task.arguments = ["site", "launch", "--direct-launch", pwaId, "\"$@\""]
task.launch()
task.waitUntilExit()

In order for the updated environment to be detected by the process, it is necessary to make changes to the info.plist file by adding the following lines there.

<key>LSEnvironment</key>
<dict>
	<key>exePath</key>
	<string>/path/to/firefoxpwa</string>
	<key>pwaId</key>
	<string>PWAID</string>
</dict>

Additional Information

I tested this solution, it works fine.
The executable file was compiled using swiftc, after that I replaced the original executable with my executable and modified the info.plist file.

@filips123
Copy link
Owner

filips123 commented Jun 30, 2022

I'm pretty late because I didn't have much time. Anyway, I tried doing this but it doesn't work for me. It appears the executable does not see variables set in LSEnvironment, so the app cannot start.

Apparently LSEnvironment by processes started via "Launch Services" and not via terminal (source?). However, it also does not work for me when I try to launch it from Launchpad. Maybe it's because I'm using the old macOS 10.15.7 (the latest I could install into VM)? But in any case, I would like if launching from the terminal (using firefoxpwa site launch and open) would also work.

Is there any more reliable way of setting environment variables for a bundle? Or, is swiftc included in standard macOS out-of-the-box? This isn't the nicest solution, but maybe PWAsForFirefox could compile a new executable when installing each PWA and include exePath and pwaId directly in the source code.

Edit: I think swiftc is not included in macOS by default, but it's included in Command Line Tools for Xcode. However, considering Homebrew requires and installs Command Line Tools, I can probably assume users will have it installed. So, unless I find a way to properly set environment variables, I will just compile loader executable and installing PWA.

@filips123
Copy link
Owner

This will be released in 2.0.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Done
Development

No branches or pull requests

2 participants