How to hide terminal window in mac osx?

前端 未结 1 1017
灰色年华
灰色年华 2021-01-06 01:36

I have a multi platform application that runs on Windows, Linux, Android and Mac. It is compiled with g++ on all platforms.

For windows, I created an installer and g

相关标签:
1条回答
  • 2021-01-06 02:07

    Based on your description, you're building what is a unix-style executable. On OS X, those will always launch inside of a terminal window. The choices that you have on OS X are:

    • Run as a daemon as described in the above-linked post
    • Run in Terminal as a unix executable
    • Create a minimal OS X application wrapper and run as an OS X Application

    In most cases, you can create a wrapper for a unix-style executable by creating the appropriate Bundle using the instructions from Apple's Bundle Programming Guide (skip over the iOS stuff and look at the Mac bundle information).

    The basic directory structure is:

    MyApp.app/
      Contents/
        Info.plist
      MacOS/
        executable
      Resources/
        MyApp.icns
    

    Your unmodified executable can go in the MacOS directory, and you'll need to set up the following keys in the Info.plist using a plist editing tool or editor:

    • CFBundleIdentifier - the id of your app in reverse-dns notation (com.mycompany.myapp)
    • CFBundleDisplayName - the name of your app in human-readable form (MyApp)
    • CFBundleName - the short name of the app (usually the same as your app and executable name)
    • CFBundleVersion - your version # in X.Y[.Z] form
    • CFBundlePackageType - the package type, which should be APPL for applications
    • CFBundleExecutable - the name of your executable
    • CFBundleSignature - old-school Apple signature (4 character code that should theoretically be registered with apple)

    A minimal plist would look like this: CFBundleDisplayName MyApp CFBundleExecutable a.out CFBundleIdentifier com.mycompany.myapp CFBundleName MyApp CFBundlePackageType APPL CFBundleSignature FOOZ CFBundleVersion 1.0

    (The above example uses a.out as the executable, which would be located in MyApp.app/Contents/MacOS/a.out)

    The icon resources can be left out if you don't care about the icon, and the default application icon will be used.

    0 讨论(0)
提交回复
热议问题