Files
ghostty-rs/crates/ghostty-macos/src/helpers/app_info.rs
T
ddidderr 0137168c66 feat(macos): foundation of the macOS app ported from Swift to Rust
Phase 9, MA1: crates/ghostty-macos (AppKit via objc2; empty stub on
non-Apple targets) ports the foundation of Ghostty 1.3.1's Swift macOS
app (ghostty/macos): main, AppDelegate (+Ghostty) with lifecycle, dock
menu, open-file, notifications, shortcut sync and quit/reopen paths;
MainMenu.xib as generated menu tables built into NSMenus; the
Ghostty.App/Config/Surface wrappers driving libghostty in-process via
ghostty-lib; the generic helpers; scripts/macos-bundle.sh to assemble
Ghostty.app (dry-run on Linux). Feature areas are stubbed for MA2-MA5.
Design and type mapping: docs/rewrite/notes/macos-app-design.md
(App Intents is a Swift-only framework and cannot be ported).

Compile-checked only (no macOS here): just check-macos passes for
aarch64/x86_64-apple-darwin with -D warnings; 125 platform-independent
tests run on Linux.

Test Plan:
- just check-macos
- cargo test -p ghostty-macos
2026-10-12 19:25:44 +02:00

35 lines
961 B
Rust

//! `Helpers/AppInfo.swift`.
/// True if we appear to be running in Xcode.
#[must_use]
pub fn is_running_in_xcode() -> bool {
is_running_in_xcode_with(|k| std::env::var_os(k).is_some())
}
fn is_running_in_xcode_with(has_var: impl Fn(&str) -> bool) -> bool {
has_var("__XCODE_BUILT_PRODUCTS_DIR_PATHS")
}
/// `Bundle.main.infoDictionary?[key] as? Bool`.
#[cfg(target_vendor = "apple")]
#[must_use]
pub fn bundle_info_bool(key: &str) -> Option<bool> {
use objc2_foundation::{NSBundle, NSNumber, NSString};
let info = NSBundle::mainBundle().infoDictionary()?;
let value = info.objectForKey(&NSString::from_str(key))?;
value.downcast_ref::<NSNumber>().map(NSNumber::boolValue)
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn detects_xcode_env() {
assert!(is_running_in_xcode_with(
|k| k == "__XCODE_BUILT_PRODUCTS_DIR_PATHS"
));
assert!(!is_running_in_xcode_with(|_| false));
}
}