如何在mac osx中隐藏终端窗口? [英] How to hide terminal window in mac osx?

查看:607
本文介绍了如何在mac osx中隐藏终端窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在Windows,Linux,Android和Mac上运行的多平台应用程序。它在所有平台上用g ++编译。

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

对于windows,我创建了一个安装程序,通过添加链接器标志来摆脱终端窗口:

For windows, I created an installer and got rid of the terminal window by adding the linker flag:

-Wl,--subsystem,windows

我在Mac上寻找一个类似的选项。我从GUI中打开可执行文件时如何摆脱控制台窗口?

I am looking for a similar option on Mac. How do I get rid of the console window when I open the executable from GUI?

这个问题类似于如何隐藏控制台窗口在Mac OS(gcc编译器)?,除了我的应用程序是没有守护进程。

This question is similar to How to hide console window in Mac OS (gcc compiler)?, except that my app is no daemon.

感谢。

推荐答案

重新构建什么是unix风格的可执行文件。在OS X上,这些将始终在终端窗口内启动。您在OS X上的选择是:

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:


  • 以上面链接的帖子中描述的守护程序运行

  • 以Unix可执行文件的形式在Terminal中运行

  • 创建最小的OS X应用程序包装并作为OS X应用程序运行

在大多数情况下,您可以使用 Bundle ,为unix风格的可执行文件创建包装器developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/BundleTypes/BundleTypes.html#//apple_ref/doc/uid/10000123i-CH101-SW1\">应用程式套件程式设计指南(略过iOS的东西,看看Mac包信息)。

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).

基本目录结构是:

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

您未修改的可执行文件可以放在 MacOS 您需要使用plist编辑工具或编辑器在 Info.plist 中设置以下键:

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 - 以reverse-dns表示法显示应用程式的编号( com.mycompany.myapp

  • CFBundleDisplayName - 以人类可读形式显示的应用程式名称( MyApp

  • CFBundleName - 应用程式的简称(通常与应用程式和执行名称相同) / li>
  • CFBundleVersion - 您的版本#为XY [.Z]形式

  • CFBundlePackageType - 应用程序包类型 APPL

  • CFBundleExecutable - 可执行文件的名称

  • CFBundleSignature 理论上应该注册到苹果)

  • 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)

一个最小的plist看起来像这样:




CFBundleDisplayName
MyApp
CFBundleExecutable
a.out
CFBundleIdentifier
com.mycompany.myapp
CFBundleName
MyApp
CFBundlePackageType
APPL
CFBundleSignature
FOOZ
CFBundleVersion
1.0

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

(上面的例子使用 a.out 作为可执行文件,它位于 MyApp.app/Contents/MacOS/a。 out

(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.

这篇关于如何在mac osx中隐藏终端窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆