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

Weird MacOS binary behavior #231

Open
hypherionmc opened this issue Aug 7, 2021 · 10 comments
Open

Weird MacOS binary behavior #231

hypherionmc opened this issue Aug 7, 2021 · 10 comments

Comments

@hypherionmc
Copy link

Expected Behavior
When running neu build --release and copying the dist folder to a mac machine, I expect to be able to run the app as is

Actual Behavior
The binary opens with Text Editor. To get it to run, you have to run the following command through the terminal chmod +x appnamehere

Along with this, opening the binary also opens a terminal window that stays open, even after the app is closed. I had another mac user confirm this behavior and they've been able to replicate it

Steps to Reproduce the Problem

  1. Create a new neutralinojs app
  2. Run neu build --release
  3. Copy the dist folder to a mac machine
  4. Try to open the mac binary. It should open with text editor
  5. Run command chmod +x binaryname from a terminal inside the dist folder
  6. The app now runs, but opens a terminal window that stays open after closing the app

Specifications

  • NeutralinoJs Version: Built from Master branch, but has been present in 2.x
  • NeutralinoJs CLI version: 4.0.0
  • Platform: MacOS Big Sur 11.4
@shalithasuranga
Copy link
Member

Yeah, terminal window is expected for a typical binary in macOS. To Run as an app, you need to wrap your app as an app bundle. You can make a minimal app bundle by renaming yourapp to yourapp.app. Ref: https://en.wikipedia.org/wiki/Bundle_(macOS)

@hypherionmc
Copy link
Author

Yeah that works. Maybe this could be added as an option to neu build?

@shalithasuranga
Copy link
Member

shalithasuranga commented Aug 8, 2021

Yeah ideally the CLI needs to generate MSI (or another installation package), DMG, and Linux app image/Debian installer. But still, it's not implemented yet. I think we can check it after other pending stuff because there are tools to make such packages.

@shalithasuranga
Copy link
Member

Btw. @hypherionmc I saw you are contributing Neutralinojs a lot with ideas and commits. Would you like to get your name (and Github link) displayed in https://neutralino.js.org/docs/community/committers/ ? We maintain that list with top active contributors.

@hypherionmc
Copy link
Author

Yeah ideally the CLI needs to generate MSI (or another installation package), DMG, and Linux app image/Debian installer. But still, it's not implemented yet. I think we can check it after other pending stuff because there are tools to make such packages.

I think for now, having the binaries as .app will be a good idea, because not everyone has the technical knowledge to make the binary executable

@hypherionmc
Copy link
Author

Btw. @hypherionmc I saw you are contributing Neutralinojs a lot with ideas and commits. Would you like to get your name (and Github link) displayed in https://neutralino.js.org/docs/community/committers/ ? We maintain that list with top active contributors.

Um yeah sure. I would to get more involved in NeutralinoJS development, but I need to spend a bit of time studying the code first to understand better how everything works.

If you want, you are also welcome to include my Simple RPC editor app as a "made with neutralino" app

@shalithasuranga
Copy link
Member

Hey.. @hypherionmc I've added your Github name and link to the above page and thanks for the support. If you have some free time could you add your app to https://neutralino.js.org/apps/ by making a PR.

@amafjarkasi
Copy link

Is the app supposed to show up blank on Mac OS?

@Blatman
Copy link

Blatman commented Aug 30, 2021

Just in case other folk are having hassles with MacOS (been trying to work out all the neutralino repos) -

I tried the Neutralino CLI release download (2.7.0) but the binaries were no use to me since the mac binary is built for MacOS 11 or later and I still use MacOS 10.13 and 10.14. To rebuild the binary I needed the source download (neutralinojs repo) which has the build scripts. Using 'bash build_macos.sh' the new binary for 10.13 was built and placed in the bin folder however the executable permissions are not applied. Can be done with 'sudo chmod 755 binaryname'. Logically the permissions should be applied by the script at the point of build.

I tried the NeutralinoCLI install and it appears to be used to build app binaries for release and depends on copying pre-built binaries from the bin folder (these of course are built for later MacOS). I found that placing my newly built 10.13 binary into the bin folder of the CLI install that release builds were built OK.

The only hassle I have now is that the resulting binary isn't really MacOS ready.
If double-clicked it will run with an associated terminal window and if the file is appended with .app it will open as an app without the terminal window but the structure isn't really right for a typical Mac app since a .app file is normally a bundled folder structure rather than a single file.

I found that a .app bundle can be manually built (normally done with a build tool of course) using -

example.app

Contents (root folder)

MacOS Info.plist Resources (Contents folder)

MacOS folder --> neutralino (binary from neutralinoCLI dist renamed)
neutralino.config.json (includes pointers to icons and app resources/window sizing/etc)
Resources (app resources normally but needed to be in MacOS folder?)
neutralino.log (useful - not sure if it can be turned off)

So far I can get simple web sites encapsulted as apps but having trouble getting the app structure sorted.
eg: only seems to work if Resources is co-located with binary in MacOS but normally I have the app Resources outside the app binary folder. The app name can be set OK in the plist file.

The only real issue I have is the window won't close with the close button (quit on dock icon works great) but I'm hoping it is to do with the change in 2.7.0 and it needs to be written into js code somewhere (as per main.js in the sample).
EDIT: to get the close button working I needed to reference the neutralino.js and main.js file in the starting index.html and since the main.js includes the tray menu code it was also called. Note: initially I didn't have the trayIcon.png resource available so got a segmentation fault 11 and crash on start. Fair to say that all resources should be present to avoid segmentation errors. The neutralino.log pointed to the missing resource.

There is also a file called neu.res which I don't seem to need if the app resources are bundled in the .app package.

So - looks like it is coming together and the small bundle size is a real bonus!

UPDATE: there is a workround for the Resources folder issue that will allow a correct app bundle to be built. Issue neutralinojs/neutralinojs#577 outlines the workround - essentially the parameterized file is an executable that steers the app binary to the Resources folder specified. The app package will start with the parameterized executable as specified in the Info.plist file, the parameterized file will then call the app binary and designate the folder that the app resources are contained in. The res.neu file is not necessary in the mac bundle so if it is not present neutralino will then check the folder for app files eg: index.html

@bgbruno
Copy link

bgbruno commented Nov 14, 2022

still after run neu build - there is just {{app_name}}-mac_x64 means without extension .app

if this is problem for someone - would be great add this option in neutralino.config.json

@shalithasuranga shalithasuranga transferred this issue from neutralinojs/neutralinojs Nov 25, 2023
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

5 participants