macOS: distinguish between Debug and Release(Stable/Tip) (#9149)

### Background

Been running Ghostty locally for a while now, and I use the Finder
service a lot. It often confuses me which one is the official one, until
I actually open it.

### Changes

- Use blueprint to distinguish from release app, if no custom icon
specified
- Change BundleDisplayName to Ghostty[Debug]
- Enable Info.plist preprocessing for reading
`$(INFOPLIST_KEY_CFBundleDisplayName)` for providing different services
with different configurations
> (Preprocessing was once reverted
before](https://github.com/ghostty-org/ghostty/commit/6508fec), so I'm
not sure whether this follows the 'rules' here, but for now, there are
no links in the plist file, so I think it’s
[safe](https://developer.apple.com/library/archive/technotes/tn2175/_index.html#:~:text=can%20pass%20the-,%2Dtraditional,-flag%20to%20the)
to enable it
pull/9170/head
Xiangbao Meng 2025-10-12 22:07:29 +02:00 committed by GitHub
parent 8d8821004e
commit 03e71e86a4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 12 additions and 4 deletions

View File

@ -61,7 +61,7 @@
<key>NSMenuItem</key>
<dict>
<key>default</key>
<string>New Ghostty Tab Here</string>
<string>New $(INFOPLIST_KEY_CFBundleDisplayName) Tab Here</string>
</dict>
<key>NSMessage</key>
<string>openTab</string>
@ -80,7 +80,7 @@
<key>NSMenuItem</key>
<dict>
<key>default</key>
<string>New Ghostty Window Here</string>
<string>New $(INFOPLIST_KEY_CFBundleDisplayName) Window Here</string>
</dict>
<key>NSMessage</key>
<string>openWindow</string>

View File

@ -553,6 +553,7 @@
INFOPLIST_KEY_NSRemindersUsageDescription = "A program running within Ghostty would like to access your reminders.";
INFOPLIST_KEY_NSSpeechRecognitionUsageDescription = "A program running within Ghostty would like to use speech recognition.";
INFOPLIST_KEY_NSSystemAdministrationUsageDescription = "A program running within Ghostty requires elevated privileges.";
INFOPLIST_PREPROCESS = YES;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
@ -775,7 +776,7 @@
EXECUTABLE_NAME = ghostty;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = "Ghostty-Info.plist";
INFOPLIST_KEY_CFBundleDisplayName = Ghostty;
INFOPLIST_KEY_CFBundleDisplayName = "Ghostty[DEBUG]";
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.developer-tools";
INFOPLIST_KEY_NSAppleEventsUsageDescription = "A program running within Ghostty would like to use AppleScript.";
INFOPLIST_KEY_NSBluetoothAlwaysUsageDescription = "A program running within Ghostty would like to use Bluetooth.";
@ -793,6 +794,7 @@
INFOPLIST_KEY_NSRemindersUsageDescription = "A program running within Ghostty would like to access your reminders.";
INFOPLIST_KEY_NSSpeechRecognitionUsageDescription = "A program running within Ghostty would like to use speech recognition.";
INFOPLIST_KEY_NSSystemAdministrationUsageDescription = "A program running within Ghostty requires elevated privileges.";
INFOPLIST_PREPROCESS = YES;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
@ -847,6 +849,7 @@
INFOPLIST_KEY_NSRemindersUsageDescription = "A program running within Ghostty would like to access your reminders.";
INFOPLIST_KEY_NSSpeechRecognitionUsageDescription = "A program running within Ghostty would like to use speech recognition.";
INFOPLIST_KEY_NSSystemAdministrationUsageDescription = "A program running within Ghostty requires elevated privileges.";
INFOPLIST_PREPROCESS = YES;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
@ -865,7 +868,7 @@
A5D449A82B53AE7B000F5B83 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = Ghostty;
ASSETCATALOG_COMPILER_APPICON_NAME = "Ghostty-Debug";
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;

View File

@ -121,7 +121,12 @@ class AppDelegate: NSObject,
/// The custom app icon image that is currently in use.
@Published private(set) var appIcon: NSImage? = nil {
didSet {
#if DEBUG
// if no custom icon specified, we use blueprint to distinguish from release app
NSApplication.shared.applicationIconImage = appIcon ?? NSImage(named: "BlueprintImage")
#else
NSApplication.shared.applicationIconImage = appIcon
#endif
let appPath = Bundle.main.bundlePath
NSWorkspace.shared.setIcon(appIcon, forFile: appPath, options: [])
NSWorkspace.shared.noteFileSystemChanged(appPath)