Ich versuche, meine Binärdatei in einem minimalistischen App-Bundle zu verpacken. Aber ich sehe ein seltsames Verhalten mit dem Ergebnis.Packaging C binär in Mac OS X Application-Paket
Mein Bündel hat diese minimale Struktur:
$ ls -R HelloWorld.app
Contents
HelloWorld.app/Contents:
Info.plist MacOS PkgInfo
HelloWorld.app/Contents/MacOS:
helloworld
Hello World ist ein C binär aus kompiliert:
#include <stdio.h>
#include <unistd.h>
int main(int argc, char **argv) {
while (1) {
printf("Hello world!\n");
sleep(2);
}
return 0;
}
Info.plist enthält:
<?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>CFBundleExecutable</key>
<string>helloworld</string>
<key>CFBundleIdentifier</key>
<string>com.litl.helloworld</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>HelloWorld</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0.0</string>
<key>CFBundleVersion</key>
<string>20</string>
<key>LSMinimumSystemVersion</key>
<string>10.6</string>
<key>LSUIElement</key>
<true/>
<key>LSBackgroundOnly</key>
<true/>
</dict>
</plist>
Jetzt für das seltsame Verhalten . Wenn ich rufe
open ./HelloWorld.app
Der Befehl hängt für ca. 30s. Danach kann ich bestätigen, dass die Helloworld-Binärdatei läuft. Die Standardausgabe wird jedoch nicht in Console.app angezeigt. Wenn ich dieses Paket programmgesteuert (NSWorkspace sharedWorkspace) launchApplicationAtURL ...) starte, ist der Aufruf erfolgreich, aber die Binärdatei wird sofort beendet (ich kann in der Konsole sehen, dass sie mit Fehlercode 2 beendet wurde).
Dies ist unter OS X 10.9.2.
Was mache ich falsch?