Joh*_*ien 6 macos bundle launchd app-bundle
我正在尝试将我的二进制文件打包到一个简约的应用程序包中.但是我看到结果有些奇怪的行为.
我的包有这个最小的结构:
$ ls -R HelloWorld.app
Contents
HelloWorld.app/Contents:
Info.plist MacOS PkgInfo
HelloWorld.app/Contents/MacOS:
helloworld
Run Code Online (Sandbox Code Playgroud)
helloworld是一个C二进制文件,编译自:
#include <stdio.h>
#include <unistd.h>
int main(int argc, char **argv) {
while (1) {
printf("Hello world!\n");
sleep(2);
}
return 0;
}
Run Code Online (Sandbox Code Playgroud)
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>
Run Code Online (Sandbox Code Playgroud)
现在为了奇怪的行为.我跑的时候
open ./HelloWorld.app
Run Code Online (Sandbox Code Playgroud)
该命令挂起约30秒.之后,我可以确认helloworld二进制文件正在运行.但是它的标准输出不会出现在Console.app中.如果我以编程方式启动此捆绑包(NSWorkspace sharedWorkspace)launchApplicationAtURL ...)调用成功,但二进制文件立即退出(我可以在控制台中看到它退出时出现错误代码2).
这是在OS X 10.9.2上.
我究竟做错了什么?
| 归档时间: |
|
| 查看次数: |
1079 次 |
| 最近记录: |