JPFrancoia
JPFrancoia

Reputation: 5629

Modify Info.plist to launch app

I'm trying to build a simple app, launchable by the final user with a simple double-click.

Here is the folder tree I have:

MyProgram.app/
    Contents/
        Info.plist
        MacOS/
            exe_not_exe --> this is a dummy exe, but needed
    MyProgram-mac-os-x86_64/
        MyProgram.app/   ---> THIS APP is executable
        Contents/
            Info.plist
            MacOS/
                exe_really_exe --> this is the exe really executed

I would like that when the user double-clicks the first MyProgram.app, the application starts, but uses in fact exe_really_exe, not exe_not_exe.

The first Info.plist has somewhere the key:

<key>CFBundleExecutable</key>
<string>exe_not_exe</string>

So I tried to build this tree folder instead:

MyProgram.app/
        Contents/
            Info.plist
            MacOS/
                exe_not_exe
                launcher --> this is a new file
        MyProgram-mac-os-x86_64/
            MyProgram.app/
            Contents/
                Info.plist
                MacOS/
                    exe_really_exe

And in the launcher file:

#!/usr/bin/env bash
open ../../MyProgram-mac-os-x86_64/MyProgram.app

open ../../MyProgram-mac-os-x86_64/MyProgram.app/MacOS/exe_really_exe

(I tried the two different instructions). If I start the launcher file from its directory, everything works as expected.

I modified the Info.plist (the highest one in the tree):

<key>CFBundleExecutable</key>
<string>launcher</string>

But finally, if I double-click MyProgram.app (the highest one in the tree), the application doesn't start. If I start it from the command line, I get the error:

LSOpenURLsWithRole() failed with error -10810 for the file MyProgram.app/

Could you help me to find out what is wrong with my procedure please ?

Upvotes: 4

Views: 3277

Answers (1)

JPFrancoia
JPFrancoia

Reputation: 5629

It appears I was doing everything right. But I needed to rename the .app bundle, and rename it back. Mac OS needs to "reload" the Info.plist, otherwise the changes don't count. That's completely stupid and silly, and it tool me ages to figure it out.

Upvotes: 2

Related Questions