Xcode - 如何更改 macOS 应用程序的显示名称?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/42847580/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 09:50:45  来源:igfitidea点击:

Xcode - How to change the display name of an app for macOS?

xcodemacos-sierra

提问by Cue

The product name of the app is the name of your app as it will appear to customers and you choose it in the Xcode Assistant when starting a new project, but what if you would like to change it?

应用程序的产品名称是您的应用程序的名称,因为它会向客户显示并且您在启动新项目时在 Xcode 助手中选择它,但是如果您想更改它怎么办?

It seems a trivial question but I tried searching and I find old answers like this one Changing Cocoa display name in the app?(seven years ago) or this one How to change the name of a Mac application in the build settings?which assumes you have a MainMenu.xib file, or answers that refer to iPhone as for example this answer (nine years ago) How to change the name of an iOS app?or this Apple's Technical note for iOS.

这似乎是一个微不足道的问题,但我尝试搜索并找到了像这样的旧答案在应用程序中更改 Cocoa 显示名称?(七年前)或这个如何在构建设置中更改 Mac 应用程序的名称?假设您有一个 MainMenu.xib 文件,或引用 iPhone 的答案,例如这个答案(九年前)如何更改 iOS 应用程序的名称?或此Apple 的 iOS 技术说明

Because many things may have changed in Xcode since seven or more years and macOS is different from iOS, I'm afraid to create some trouble, or to change the name that appears in some parts, but forget the old name in another place.

因为七年或更长时间以来Xcode中的很多东西可能已经发生了变化,而macOS与iOS不同,所以我害怕制造一些麻烦,或者更改某些部分出现的名称,但在另一个地方忘记了旧名称。

What is the correct way to change the name that the user sees in an app for Mac?

更改用户在 Mac 应用程序中看到的名称的正确方法是什么?

回答by Jens Meder

There are several ways to change the name of the app, after you have created the project:

创建项目后,有多种方法可以更改应用程序的名称:

  1. You can rename the target (Double click on the name) because by default Xcode uses the target name as product's name (see next screenshot). Target name

  2. You can set the product name directly in the build settings or via xcconfig files. I actually prefer this way because you can create different names for different build configurations, e.g., "MyApp Debug", "MyApp Beta", "MyApp". So just replace the $(TARGET_NAME)with the name of your app. Build settings beforeBuild settings after

  1. 您可以重命名目标(双击名称),因为默认情况下 Xcode 使用目标名称作为产品名称(参见下一个屏幕截图)。 目标名称

  2. 您可以直接在构建设置中或通过 xcconfig 文件设置产品名称。我实际上更喜欢这种方式,因为您可以为不同的构建配置创建不同的名称,例如,“MyApp Debug”、“MyApp Beta”、“MyApp”。因此,只需将 替换$(TARGET_NAME)为您的应用程序名称即可。 之前构建设置构建设置之后