6
我想將我的二進制文件打包到一個簡約應用程序包中。但是我看到了一些奇怪的結果。在Mac OS X應用程序包中打包C二進制文件
我的包有這個最小的結構:
$ ls -R HelloWorld.app
Contents
HelloWorld.app/Contents:
Info.plist MacOS PkgInfo
HelloWorld.app/Contents/MacOS:
helloworld
HelloWorld的是C二進制編譯自:
#include <stdio.h>
#include <unistd.h>
int main(int argc, char **argv) {
while (1) {
printf("Hello world!\n");
sleep(2);
}
return 0;
}
的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>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>
現在的奇怪行爲。當我運行時
open ./HelloWorld.app
該命令掛起大約30秒。之後,我可以確認helloworld二進制文件正在運行。但是它的標準輸出不會顯示在Console.app中。如果我以編程方式啓動此捆綁包(NSWorkspace sharedWorkspace)launchApplicationAtURL ...),則調用成功,但二進制文件立即退出(我可以在控制檯中看到它退出時出現錯誤代碼2)。
這是在OS X 10.9.2上。
我在做什麼錯?