3

I have a problem with a Mac OSX app bundle. If I want to run my app bundle nothing happens (double clicking myApp.app).

I can run the app by executing ./myApp.app/Contents/MacOS/myApp without any problem.

The directory structure:

myApp.app/
    Contents/
        Info.plist
        PkgInfo
        Resources/
        Frameworks/
        MacOS/
            myApp

My Info.plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>CFBundleDevelopmentRegion</key>
    <string>en</string>
    <key>CFBundleExecutable</key>
    <string>myApp</string>
    <key>CFBundleIconFile</key>
    <string>icon</string>
    <key>CFBundleIdentifier</key>
    <string>com.whatever.test</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleName</key>
    <string>${PRODUCT_NAME}</string>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>CFBundleShortVersionString</key>
    <string>1.0.0</string>
    <key>CFBundleSignature</key>
    <string>com.whatever.test</string>
    <key>CFBundleVersion</key>
    <string>1.0.0</string>
    <key>LSMinimumSystemVersion</key>
    <string>${MACOSX_DEPLOYMENT_TARGET}</string>
    <key>NSHumanReadableCopyright</key>
    <string>Copyright © 2014. All rights reserved.</string>
</dict>
</plist>

Edit:

Console.app result:

08.02.14 16:30:45,041 com.apple.launchd.peruser.501[1077]: (com.whatever.test.72544[20350]) Job failed to exec(3) for weird reason: 13
08.02.14 16:30:45,043 Finder[1094]: 8837325: Attempting to SIGCONT to pid #20350 failed, with errno=#3, or the process failed to actually start
08.02.14 16:30:45,046 Dock[1091]: no information back from LS about running process LSASN:{hi=0x0;lo=0x168168}
Bastl
  • 883
  • 2
  • 10
  • 27

3 Answers3

0

I don't think you have your code properly signed, given you're missing a _CodeSignature directory. Thus GateKeeper may be blocking the code from running.

You have two options:

  • Code sign your code.
  • Controlclick the app bundle and then choose Open - it'll bypass the code signature check.
ArtOfWarfare
  • 20,617
  • 19
  • 137
  • 193
  • 1
    Yes, the code is not signed. But using the `control` key does also not work. The interesting thing is: sometimes I can see a white window for ~0.5 seconds – Bastl Feb 08 '14 at 15:36
0

This line:

08.02.14 16:30:45,041 com.apple.launchd.peruser.501[1077]: (com.whatever.test.72544[20350]) Job failed to exec(3) for weird reason: 13

Is leading me to think that you have a Permission Denied problem based on this man page:

https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man2/intro.2.html

ArtOfWarfare
  • 20,617
  • 19
  • 137
  • 193
  • Any hint for solving this issue? – Bastl Feb 08 '14 at 15:45
  • @Bastl - I think we'd need to see the actual code that's running to give you better help. I'm wondering if maybe launching the executable directly rather than through the bundle is somehow giving it more privileges than it would otherwise have. – ArtOfWarfare Feb 08 '14 at 16:02
  • I don't think that posting the code would be a great idea, because its a very huge project :) – Bastl Feb 08 '14 at 16:09
  • 1
    @Bastl - Post the relevant code. The fact you're getting permission denied likely means that there's a file read or write operation involved. The fact it happens near the start means it happens in code which is run near the start of your project. Possibly you should add some debug messages throughout your code so that you can narrow down where the bug is occurring - they'll be sent to Console. – ArtOfWarfare Feb 08 '14 at 16:22
  • @Bastl It' seems that's a permission issue, removing exec for other : `-rwxr-xr-- 1 root wheel` on a test application give the same error. But yours are correct for a newly compiled app. – Emmanuel Feb 08 '14 at 16:25
  • I have found the problem: It was a working dir problem. Thanks for your hints. – Bastl Feb 08 '14 at 17:07
0

It was a working directory problem. using getcwd while executing "myApp.app" gives /

I fixed it by using the bundle dir instead of getcwd:

#include <CoreFoundation/CoreFoundation.h>

std::string getBundleDir()
{
    CFBundleRef mainBundle = CFBundleGetMainBundle();
    CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(mainBundle);
    char path[PATH_MAX];
    if (!CFURLGetFileSystemRepresentation(resourcesURL, TRUE, (UInt8 *)path, PATH_MAX))
        return "";

    CFRelease(resourcesURL);

    chdir(path);

    return path;
}
Bastl
  • 883
  • 2
  • 10
  • 27