On mac, NWjs.AppFolder points to a folder too deep

  • Problem Description

    When using the expression NWjs.AppFolder, if the game runs on Mac, the path will be pointing to a folder very deep inside the .app folder.

    I would be expecting it to point instead to the parent folder of my .app, so that it remains consistant with Windows.

    Attach a Capx

    https://www.dropbox.com/s/2ri5fb6q8l06s ... .capx?dl=0

    Description of Capx

    It simply displays the path from NWjs.AppFolder

    Steps to Reproduce Bug

    • Open the attached appfolder.capx
    • Export it using NW (Note: Do not try to launch it in the editor, that won't show the bug)
    • Navigate to the exported folder > osx64
    • Launch newproject.app
    • Observe the paths displayed

    Observed Result

    The path displayed (NWjs.AppFolder) is located deep within the app package.

    Example: /Users/me/Downloads/osx64/newproject.app/Contents/Versions/53.0.2785.89/nwjs Helper.app/Contents/MacOS/

    Screenshot:

    Expected Result

    NWjs.AppFolder path points to the parent folder where the .app is located. That would be the same behavior as on Windows.

    Example: /Users/me/Downloads/osx64/

    Affected Browsers

    • Chrome: no
    • FireFox: no
    • Internet Explorer: no
    • NW.js : Yes
    • Windows : no
    • Mac: yes

    Operating System and Service Pack

    Mac OSX El Capitan 10.11.6

    Construct 2 Version ID

    r252

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Found a workaround.

    First, create a variable "workpath".

    Then detect the platform. If windows, set workpath to nwjs.appfolder as usual. But if on Mac, then append a bunch of "../../../../" to bring you back to the correct folder.

  • wwwwwaaa thank you narFsnw !

  • narFsnw, could you please help me a little bit more with this : what do you write exactly in the Path field in case the platform is a mac ?

    Thanks !

  • Found a workaround.

    First, create a variable "workpath".

    Then detect the platform. If windows, set workpath to nwjs.appfolder as usual. But if on Mac, then append a bunch of "../../../../" to bring you back to the correct folder.

    I'm sorry to insist, narFsnw but if you found a workaround, it would really help me a LOT to know it.

    Then I could try to use Construct 3 efficiently on my Mac.

    Cheers !

  • The AppFolder expression returns the folder of the main executable file that started the app. On mac this happens to be in a subfolder. So it's working as expected, it's just the folder structure of an app is different on mac. (I can see the naming might be misleading, but this is how it's implemented right now.)

    What are you trying to do with the AppFolder expression that needs it to point to the folder containing the .app subfolder instead?

  • Ashley

    I have a config file that is sitting next to the app. Users need to be able to reach and open that file to configure the app. Then the app automatically look for that file and reads it.

    So, in the folder, there's:

    * bot.app

    * config.json

    I could, of course, put the config elsewhere, like in the user folder, but the user folder on mac is hidden by default, making it difficult for users to find it for edit.

    If I use NWjs.AppFolder as is, it will search for the config file deep inside the .app, making it super hard for users to find it. Also, I think it's against Apple's Mac Appstore regulation for an app to edit stuff within itself, or the ask the user to do it.

    Another workaround could be to ask the user, at launch, to locate the config file using the file explorer action, but my app is meant to be fully automated : launch, do it's thing and close without user input. So I can't do that either.

    I hope this explanation helps you understand better.

  • OK, hmm, well not sure how to reliably get that with the available NW.js APIs. I've posted a message on the NW.js group to ask about it.

    In the mean time I think a one-off setup after install to choose a file path would be an acceptable solution.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)