filips123 / PWAsForFirefox

A tool to install, manage and use Progressive Web Apps (PWAs) in Mozilla Firefox
https://pwasforfirefox.filips.si
Mozilla Public License 2.0
2.26k stars 52 forks source link

MacOS. You can't open the application "..." because it may be damaged or incomplete. #525

Open relink2013 opened 3 months ago

relink2013 commented 3 months ago

Any app I create shows You can't open the application "app_name" because it may be damaged or incomplete. when trying to launch it.

I was originally using Waterfox but to simplify troubleshooting I switched to Firefox. When I made the switch I removed any trace of Waterfox, Firefox, and the PWA extension, runtime, and connector.

I then Re-Installed Firefox from a fresh download. Installed the PWA Extension, installed the connector from home-brew and installed the default runtime from the PWA extension itself.

Everything appears fine and there are no errors in the extensions console. However the debug log does show numerous errors all seemingly related to the icon...

Im not sure what else to try. I ran through all the troubleshooting steps including the total re-install mentioned above more than once. Especially considering everything works perfectly on my other Mac which is configured exactly the same.

The attached log shows only one attempt to create and launch a ChatGPT PWA in a fresh profile..

firefoxpwa.log

macOS Sonoma 14.5 Intel Core i5 Extension Ver: 2.12.1 Firefox Ver: 128.0.3

filips123 commented 3 months ago

Well, that's weird... Can you check what happens if you try to launch the PWA from terminal using firefoxpwa site launch SITE-ID? Also, can you try to directly run the Contents/MacOS/loader file inside the PWA bundle?

relink2013 commented 3 months ago

Running firefoxpwa site launch 01J3QPF130757MSP12YPC35YQD give the following output, and the app did not open.

The application cannot be opened for an unexpected reason, error=Error Domain=NSOSStatusErrorDomain Code=-10827 "kLSNoExecutableErr: The executable is missing" UserInfo={_LSLine=4129, _LSFunction=_LSOpenStuffCallLocal}

Checking the contents of /Users/ME/Applications/ChatGPT.app/Contents/MacOS there is no loader, the folder is completely empty.

filips123 commented 3 months ago

Do you have Command Line Tools for Xcode installed? You can install them with xcode-select --install.

I'm not sure if this is the problem though, as if you didn't have them, logs should contain a warning message. And the loader should have been created before downloading the icons, so I don't know why it's missing.

Can you check if editing/updating the PWA from the extension fixes the issue? Also, does theproblem happen only with ChatGPT or also with other PWAs?

relink2013 commented 3 months ago

I tried again with another fresh install of Firefox and noticed this in the stderr.log

12:54:56 [INFO] Web app installed: 01J49JGJXD66GACYFWDK224PHG
12:54:56 [DEBUG] (1) firefoxpwa::integrations::implementation::macos: Verifying that /Users/user/Applications/ChatGPT.app is a web app bundle
12:54:56 [DEBUG] (1) firefoxpwa::integrations::implementation::macos: Verifying if a bundle is a web app
12:54:56 [DEBUG] (1) firefoxpwa::integrations::implementation::macos: 'APPLFFPWA-01J49JGJXD66GACYFWDK224PHG' should be 'APPLFFPWA-01J49JGJXD66GACYFWDK224PHG'
12:54:56 [DEBUG] (1) firefoxpwa::integrations::implementation::macos: Launching web app bundle
The application cannot be opened for an unexpected reason, error=Error Domain=NSOSStatusErrorDomain Code=-10827 "kLSNoExecutableErr: The executable is missing" UserInfo={_LSLine=4129, _LSFunction=_LSOpenStuffCallLocal}
filips123 commented 3 months ago

Unfortunately, I still don't know why this happens.

You can try to manually create and compile a loder file and check if it works:

Create a Swift file:

import Foundation
let task = Process()
task.launchPath = "{firefoxpwa-exe}"
task.arguments = ["site", "launch", "--direct-launch", "{ulid}"] + CommandLine.arguments[1...]
task.launch()
task.waitUntilExit()

You should replace {firefoxpwa-exe} with the path to firefoxpwa binary, and {ulid} with your PWA ULID (for example, 01J49JGJXD66GACYFWDK224PHG).

Compile the file:

swiftc -O -o loader firefoxpwa-loader.swift

Copy the compiled loader binary into Contents/MacOS/.

relink2013 commented 2 months ago

The file I created is:

import Foundation
let task = Process()
task.launchPath = "/usr/local/Cellar/firefoxpwa/2.12.1/bin/firefoxpwa"
task.arguments = ["site", "launch", "--direct-launch", "01J4MCBAQWXMW5KXF58NCJTGV1"] + CommandLine.arguments[1...]
task.launch()
task.waitUntilExit()

But when I tried to compile it I got the following:

swiftc -O -o loader /Users/rlxc/Desktop/ffpwa-rm.swift
/Users/rlxc/Desktop/ffpwa-rm.swift:1:8: error: no such module 'Foundation'
import Foundation
       ^
filips123 commented 2 months ago

Appearently Foundation module isn't available? But isn't it part of the Swift's standard library?

Can you please try to reinstall Xcode Command Line Tools with xcode-select --install and try again?

relink2013 commented 2 months ago

Ok problem seems to have been solved!

When I ran xcode-select --install I just got a message saying it's already installed. After some searching I found a super simple solution.

remove the current install of the Xcode Command Line Tools with: sudo rm -rf /Library/Developer/CommandLineTools

Then install a fresh copy using: xcode-select --install

Loader compiled on the first try, moved it into Contents/MacOS/ and the PWA fired right up!

I have also tried creating new PWAs using the extension directly in Firefox and that now works properly too.

filips123 commented 2 months ago

I'm not sure why this happened, but it's nice to see that you were able to fix it. Maybe your Xcode CLT installation was somehow corrupted.

I will add better handling to the system integration that checks if the loader has been compiled successfully and displays the error if needed, instead of just failing silently. So, if this happens in the future, it will be at least easier to debug.