2014-03-25 5 views
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입니다.

내가 뭘 잘못하고 있니?

답변

2

애플리케이션을 반응 형으로 표시하고 '준비'하려면 Cocoa에 등록해야합니다. 도크 아이콘을 활성화하면 바운스가 멈추는 것을 의미합니다. 귀하의 경우, 도크에서 아이콘을 숨기면 Cocoa에 등록해야합니다.

이렇게 할 수 있습니다. 예 : NSApplication 클래스를 만듭니다. 저수준 배출 장치에 대해서는 here을 참조하십시오.