[Solved]Binary app file which added by projucer or ZipFile can't run after release/rebuild/unzip it

This issue only on macOS (.app file).

Normal on Windows (.exe file). Haven’t tested on Linux.

Could this be due to internal symlinks or something like that? I don’t think Juce’s ZipFile class will preserve symlinks for example (which would be a problem for apps signed with PACE for example).

Of course an .app file is really a directory so are you adding the zipped .app to the Projucer or all the individual files?

Oh, yes! I forgot this! Perhaps this is the core of why I failed to do it…

If you unzip on OS X using 3rd party software like Keka the executable flag is stripped which leads to this behavior. The same might happen when using JUCE for unzipping.

1 Like

Yes, the same. I use JUCE ZipFile class to zip and unzip the .app file. However, use the default unzip of macOS’s finder have no this problem…

The juce ZipFile stuff doesn’t attempt to set any file permissions, it just creates the files and copies their content. It won’t attempt to guess file types and look for executables or anything like that.

So, if I want to embed an app file’s data in my software and release/rebuild it when user first launch the software, is there an easy way to solve my problem, Jules?

For example: lame.app/lame.exe…

Just use File::setExecutePermission() before you run it

1 Like

Before run my software or users run the embeded app file which released on their local?

I’ve no idea what you’re doing, but I guess you probably just want to set that flag after you unzip it.

Ha, it works!
This method is exactly what I need! I love you, Jules :slight_smile:

Here is my code, you’ll find out what I’m doing:)

URL url;

    lameEncoder = File::getSpecialLocation (File::userDocumentsDirectory).getChildFile ("lame.exe");
    url = URL::createWithoutParsing ("https:/xxxx.xxx/lame-win.zip");

#elif JUCE_MAC
    lameEncoder = File::getSpecialLocation (File::userDocumentsDirectory).getChildFile ("lame.app");
    url = URL::createWithoutParsing ("https://xxxx.xxx/lame-osx.zip");

    if (!lameEncoder.existsAsFile())
        MemoryBlock mb;
        // put it in userDocumentsDirectory
        if (url.readEntireBinaryStream (mb))
            MemoryInputStream inputSteam (mb, false);
            ZipFile zip (inputSteam);
            zip.uncompressEntry (0, File::getSpecialLocation (File::userDocumentsDirectory));

            lameEncoder.setExecutePermission (true);