Skip to content

Lightweight native Discord client for Windows, Linux and macOS, written in Rust. No Electron, no browser engine.

Build RustCord for macOS

VRonGitHube39e9a52c001
diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml
new file mode 100644
index 0000000..12de88b
--- /dev/null
+++ b/.github/workflows/macos.yml
@@ -0,0 +1,114 @@
+# Builds RustCord for macOS on GitHub's machines: an Apple Silicon and an Intel
+# build, joined into one RustCord.app in a .dmg. Every run starts the app on a
+# Mac and keeps screenshots of it; every push gets the .dmg under the run's
+# "Artifacts", and a published release also gets it attached next to the
+# Windows installer.
+name: macOS build
+
+on:
+ push:
+ branches: [main, macos]
+ pull_request:
+ release:
+ types: [published]
+ workflow_dispatch:
+
+permissions:
+ contents: read
+
+env:
+ # The oldest macOS RustCord runs on, for Rust and the bundled C libraries alike.
+ MACOSX_DEPLOYMENT_TARGET: "11.0"
+
+jobs:
+ build:
+ strategy:
+ matrix:
+ include:
+ - target: aarch64-apple-darwin
+ runner: macos-15
+ - target: x86_64-apple-darwin
+ runner: macos-15-intel
+ runs-on: ${{ matrix.runner }}
+ steps:
+ - uses: actions/checkout@v7
+
+ - name: Install nasm
+ # The H.264 decoder's assembly on Intel (it builds without, slower).
+ if: matrix.target == 'x86_64-apple-darwin'
+ env:
+ HOMEBREW_NO_AUTO_UPDATE: "1"
+ HOMEBREW_NO_INSTALL_CLEANUP: "1"
+ run: brew install nasm
+
+ - uses: dtolnay/rust-toolchain@stable
+ with:
+ targets: ${{ matrix.target }}
+
+ - uses: Swatinem/rust-cache@v2
+ with:
+ key: ${{ matrix.target }}
+
+ - name: Build
+ # The badge registry's address comes from a repository secret, like
+ # registry-url.local on Windows; without it the build has no registry.
+ env:
+ RUSTCORD_REGISTRY_URL: ${{ secrets.RUSTCORD_REGISTRY_URL }}
+ run: cargo build --locked --release -p rustcord --target ${{ matrix.target }}
+
+ - uses: actions/upload-artifact@v7
+ with:
+ name: rustcord-${{ matrix.target }}
+ path: target/${{ matrix.target }}/release/rustcord
+ retention-days: 3
+
+ test:
+ # Next to the builds, on Apple Silicon: the Intel build is the same code.
+ runs-on: macos-15
+ steps:
+ - uses: actions/checkout@v7
+
+ - uses: dtolnay/rust-toolchain@stable
+
+ - uses: Swatinem/rust-cache@v2
+
+ - name: Test
+ run: cargo test --locked -p discord -p rencord -p voice -p rustcord
+
+ package:
+ needs: build
+ runs-on: macos-15
+ permissions:
+ contents: write
+ steps:
+ - uses: actions/checkout@v7
+
+ - uses: actions/download-artifact@v8
+ with:
+ pattern: rustcord-*
+
+ - name: Package
+ run: sh packaging/macos/package.sh rustcord-aarch64-apple-darwin/rustcord rustcord-x86_64-apple-darwin/rustcord
+
+ - name: Smoke test
+ run: sh packaging/macos/smoke-test.sh
+
+ - uses: actions/upload-artifact@v7
+ if: always()
+ with:
+ name: rustcord-macos-smoke-test
+ path: dist/smoke/
+ if-no-files-found: ignore
+
+ - uses: actions/upload-artifact@v7
+ with:
+ name: rustcord-macos-universal
+ path: |
+ dist/*.dmg
+ dist/*.dmg.sha256
+
+ - name: Attach to the release
+ if: github.event_name == 'release'
+ env:
+ GH_TOKEN: ${{ github.token }}
+ run: gh release upload "${{ github.event.release.tag_name }}" dist/*.dmg dist/*.dmg.sha256 --clobber
diff --git a/Cargo.lock b/Cargo.lock
index 747914d..859833c 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -5504,10 +5504,14 @@ dependencies = [
"gtk",
"image",
"keyring",
+ "libc",
"libmimalloc-sys",
"log",
"memmap2",
"mimalloc",
+ "objc2 0.6.5",
+ "objc2-app-kit 0.3.2",
+ "objc2-foundation 0.3.2",
"rand 0.8.8",
"rencord",
"reqwest",
diff --git a/README.md b/README.md
index 5213585..ba2145b 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@
# RustCord
-**A lightweight, native Discord client for Windows and Linux, written in Rust.**<br>
+**A lightweight, native Discord client for Windows, Linux and macOS, written in Rust.**<br>
No Electron, no browser engine: one small program that looks and feels like Discord.
<a href="#downloads">πŸ“¦ Downloads</a> β€’
@@ -22,7 +22,7 @@ No Electron, no browser engine: one small program that looks and feels like Disc
[![Stars](https://img.shields.io/github/stars/VRonGitHub/RustCord?color=f0b232)](https://github.com/VRonGitHub/RustCord/stargazers)
![Rust](https://img.shields.io/badge/rust-1.88%2B-dea584?logo=rust)
![UI](https://img.shields.io/badge/ui-egui%20%2F%20OpenGL-e67e22)
-![Platform](https://img.shields.io/badge/platform-Windows%20%7C%20Linux%20(experimental)-0078d6)
+![Platform](https://img.shields.io/badge/platform-Windows%20%7C%20Linux%20%7C%20macOS%20(experimental)-0078d6)
[![License](https://img.shields.io/badge/license-PolyForm%20Noncommercial-ed4245)](LICENSE)
<img src="docs/screenshots/chat.png" width="900" alt="RustCord showing a server's chat, channel list and member list">
@@ -58,6 +58,20 @@ administrator rights needed.
- New on Linux, so please [report problems](https://github.com/VRonGitHub/RustCord/issues).
Check your download with `sha256sum -c RustCord-<version>-linux-x86_64.tar.gz.sha256`.
+**macOS (experimental):** download **`RustCord-<version>-macos-universal.dmg`**, open it and drag
+RustCord into Applications. One app for Apple Silicon and Intel Macs, macOS 11 or newer.
+
+- It isn't notarized by Apple, so macOS blocks the first start: try to open it once, then choose
+ **System Settings β†’ Privacy & Security β†’ Open Anyway**. (Or in Terminal:
+ `xattr -dr com.apple.quarantine /Applications/RustCord.app`.)
+- After an update macOS may ask whether RustCord can use its saved login in your Keychain:
+ **Always Allow**. It asks for the microphone in your first call.
+- Chat, voice calls, Rich Presence and the unread badge on the Dock icon work; Go Live screen
+ sharing, the camera, video attachments, desktop notifications and spell checking are
+ Windows-only for now.
+- New on macOS, so please [report problems](https://github.com/VRonGitHub/RustCord/issues).
+ Check your download with `shasum -a 256 -c RustCord-<version>-macos-universal.dmg.sha256`.
+
<a id="highlights"></a>
## ⚑ Highlights
@@ -67,7 +81,7 @@ administrator rights needed.
- πŸŽ™οΈ **Voice, video and Go Live:** calls with noise suppression, camera, screen sharing up to 60 fps, soundboard.
- 🧩 **Rencord:** a built-in mod system with ports of popular Vencord plugins, plus Vencord/BetterDiscord themes.
- πŸ”’ **Private:** no telemetry, no tracking calls, your token stays in your system's credential store.
-- 🐧 **Windows and Linux:** a Windows installer, and an experimental Linux build.
+- πŸ–₯️ **Windows, Linux and macOS:** a Windows installer, and experimental Linux and macOS builds.
<a id="showcase"></a>
## ✨ Showcase
@@ -153,6 +167,23 @@ sh packaging/linux/package.sh # dist/RustCord-<version>-linux-x86_64.tar
</details>
+<details>
+<summary><b>Building on macOS</b></summary>
+
+Install Rust, Git and the Xcode Command Line Tools (`xcode-select --install`), plus CMake
+(`brew install cmake`), then build it:
+
+```sh
+cargo build --release -p rustcord # the program: target/release/rustcord
+cargo run --release -p rustcord -- --demo # or try it straight away
+```
+
+`packaging/macos/package.sh` turns an Apple Silicon and an Intel build into
+`dist/RustCord-<version>-macos-universal.dmg`; `.github/workflows/macos.yml` is the exact recipe
+GitHub uses for the releases, and starts the app on a Mac to check it.
+
+</details>
+
<details>
<summary><b>Good to know</b></summary>
@@ -295,16 +326,17 @@ are declared with `SettingDef::{bool, text, select}` and RustCord draws their UI
## πŸ”’ Privacy and security
- **Logging in** happens on Discord's own login page (password, 2FA, captcha, QR code, passkey),
- shown in an embedded browser (WebView2 on Windows, WebKitGTK on Linux) and closed as soon as
- you're in. RustCord only receives the session token, keeps it in Windows Credential Manager
- or your Linux desktop's keyring, and only ever sends it to discord.com.
+ shown in an embedded browser (WebView2 on Windows, WebKitGTK on Linux, WebKit on macOS) and
+ closed as soon as you're in. RustCord only receives the session token, keeps it in Windows
+ Credential Manager, your Linux desktop's keyring or the macOS Keychain, and only ever sends it
+ to discord.com.
- **No telemetry:** RustCord sends none and doesn't call Discord's tracking endpoints.
- **Blending in:** it presents itself to Discord as Discord's own web client, and paces its
requests like it, because clients that stand out risk being flagged by Discord's anti-spam.
- **Local data:** so your account opens instantly, a snapshot of it (servers, channels, DMs,
friends, read states; never the token) is kept in `%LOCALAPPDATA%\RustCord`, encrypted for
- your Windows account, and deleted when you log out. On Linux it's in `~/.cache/rustcord` and
- not encrypted yet.
+ your Windows account, and deleted when you log out. On Linux it's in `~/.cache/rustcord`, on
+ macOS in `~/Library/Caches/dev.RustCord.RustCord`, and not encrypted there yet.
<details>
<summary><b>Everything RustCord connects to</b></summary>
@@ -348,6 +380,7 @@ silently, and `rustcord-uninstall.exe /S [--delete-data]` removes it.
| `apps/rustcord` | The desktop app: UI (egui), account store, background network thread, demo mode |
| `apps/setup` | The Windows installer and uninstaller |
| `packaging/linux` | The Linux package: desktop entry, install script, packing script |
+| `packaging/macos` | The macOS app bundle and .dmg, and the smoke test GitHub runs on it |
| `crates/discord` | Discord's data models, REST client with rate-limit pacing, gateway |
| `crates/voice` | Voice calls, camera and Go Live, with end-to-end encryption |
| `crates/rencord` | Plugin API, built-in plugins and the theme translator |
@@ -370,7 +403,7 @@ and no automation. It can't make guarantees, though.
<summary><b>Is my token safe?</b></summary>
You log in on Discord's own page. RustCord stores the token in Windows Credential Manager (on
-Linux, your desktop's keyring), sends
+Linux, your desktop's keyring; on macOS, the Keychain), sends
it only to discord.com, never writes it to its logs or cache, and has no server of its own that
ever sees it.
@@ -379,8 +412,9 @@ ever sees it.
<details>
<summary><b>Does it run on macOS or Linux?</b></summary>
-Linux, yes, as an experimental build since 0.4.37 (see [Downloads](#downloads)): everything but
-Go Live screen sharing and the camera. macOS isn't supported yet.
+Both, as experimental builds (see [Downloads](#downloads)), macOS on Apple Silicon and Intel.
+Everything but Go Live screen sharing and the camera; on macOS also no video attachments,
+desktop notifications or spell checking yet.
</details>
diff --git a/apps/rustcord/Cargo.toml b/apps/rustcord/Cargo.toml
index 1859733..ac54d39 100644
--- a/apps/rustcord/Cargo.toml
+++ b/apps/rustcord/Cargo.toml
@@ -62,6 +62,14 @@ embed-resource = "2"
# by src/linux.rs. The version wry 0.57 uses.
gtk = "0.18"
+[target.'cfg(target_os = "macos")'.dependencies]
+# The Process Viewer's memory and processor figures (src/diagnostics.rs).
+libc = "0.2"
+# The Dock icon's unread badge (src/tray.rs), at the versions wry already uses.
+objc2 = "0.6"
+objc2-foundation = { version = "0.3", default-features = false, features = ["std", "NSString"] }
+objc2-app-kit = { version = "0.3", default-features = false, features = ["std", "NSApplication", "NSDockTile", "NSResponder"] }
+
[target.'cfg(windows)'.dependencies]
windows-sys = { version = "0.59", features = ["Win32_Foundation", "Win32_System_Diagnostics_Debug", "Win32_System_Kernel", "Win32_System_LibraryLoader", "Win32_UI_WindowsAndMessaging", "Win32_UI_Shell", "Win32_Graphics_Gdi", "Win32_Graphics_Dwm", "Win32_UI_Input_KeyboardAndMouse", "Win32_System_Registry",
# Sealing the on-disk caches (DPAPI, see src/cache.rs).
diff --git a/apps/rustcord/src/diagnostics.rs b/apps/rustcord/src/diagnostics.rs
index 3d02e80..8a3f8f6 100644
--- a/apps/rustcord/src/diagnostics.rs
+++ b/apps/rustcord/src/diagnostics.rs
@@ -249,6 +249,10 @@ pub fn working_set_mb() -> u64 {
if let Some(p) = linux_proc::read(std::process::id()) {
return p.working_set / (1024 * 1024);
}
+ #[cfg(target_os = "macos")]
+ if let Some(p) = mac_proc::read_self() {
+ return p.working_set / (1024 * 1024);
+ }
0
}
@@ -447,12 +451,68 @@ pub fn process_tree() -> Vec<ProcessInfo> {
{
linux_proc::process_tree()
}
- #[cfg(not(any(windows, target_os = "linux")))]
+ #[cfg(target_os = "macos")]
+ {
+ mac_proc::read_self().into_iter().collect()
+ }
+ #[cfg(not(any(windows, target_os = "linux", target_os = "macos")))]
{
Vec::new()
}
}
+/// The Process Viewer's numbers on macOS. RustCord alone: the WebKit
+/// processes behind its web pages are started by the system, not by RustCord.
+#[cfg(target_os = "macos")]
+mod mac_proc {
+ use super::ProcessInfo;
+
+ pub fn read_self() -> Option<ProcessInfo> {
+ let pid = std::process::id();
+ // SAFETY (the three zeroed structs): plain C structs of integers, for
+ // which all zeroes is a valid value.
+ let mut usage: libc::rusage_info_v4 = unsafe { std::mem::zeroed() };
+ // SAFETY: `usage` is the rusage_info_v4 that RUSAGE_INFO_V4 fills.
+ if unsafe { libc::proc_pid_rusage(pid as i32, libc::RUSAGE_INFO_V4, (&mut usage as *mut libc::rusage_info_v4).cast()) } != 0 {
+ return None;
+ }
+ let mut task: libc::proc_taskinfo = unsafe { std::mem::zeroed() };
+ let size = std::mem::size_of::<libc::proc_taskinfo>() as i32;
+ // SAFETY: `task` is a proc_taskinfo of the size passed.
+ let filled = unsafe { libc::proc_pidinfo(pid as i32, libc::PROC_PIDTASKINFO, 0, (&mut task as *mut libc::proc_taskinfo).cast(), size) };
+ let mut own: libc::rusage = unsafe { std::mem::zeroed() };
+ // SAFETY: `own` is the rusage getrusage fills.
+ unsafe { libc::getrusage(libc::RUSAGE_SELF, &mut own) };
+ let seconds = |t: libc::timeval| t.tv_sec as f64 + t.tv_usec as f64 / 1e6;
+ Some(ProcessInfo {
+ pid,
+ parent: std::os::unix::process::parent_id(),
+ name: std::env::current_exe().ok().and_then(|p| Some(p.file_name()?.to_str()?.to_owned())).unwrap_or_else(|| "rustcord".into()),
+ threads: if filled == size { task.pti_threadnum.max(0) as u32 } else { 0 },
+ working_set: usage.ri_resident_size,
+ // (Bytes on macOS, kilobytes on Linux.)
+ peak_working_set: own.ru_maxrss.max(0) as u64,
+ // The physical footprint: Activity Monitor's "Memory".
+ private_working_set: Some(usage.ri_phys_footprint),
+ committed: usage.ri_phys_footprint,
+ handles: std::fs::read_dir("/dev/fd").map(|d| d.count() as u32).unwrap_or(0),
+ cpu_seconds: seconds(own.ru_utime) + seconds(own.ru_stime),
+ })
+ }
+}
+
+#[cfg(all(test, any(windows, target_os = "linux", target_os = "macos")))]
+mod process_tests {
+ /// The Process Viewer finds RustCord's own process, with real figures.
+ #[test]
+ fn process_tree_starts_with_this_process() {
+ let tree = super::process_tree();
+ let me = tree.first().expect("this process");
+ assert_eq!(me.pid, std::process::id());
+ assert!(me.working_set > 0 && me.threads > 0, "{me:?}");
+ }
+}
+
/// The Process Viewer's numbers on Linux, from /proc.
#[cfg(target_os = "linux")]
mod linux_proc {
diff --git a/apps/rustcord/src/features.rs b/apps/rustcord/src/features.rs
index 09c45cd..c2e62db 100644
--- a/apps/rustcord/src/features.rs
+++ b/apps/rustcord/src/features.rs
@@ -1295,7 +1295,16 @@ impl RustCord {
self.toast(format!("Couldn't start text-to-speech (spd-say): {e}"), true);
}
}
- #[cfg(not(any(windows, target_os = "linux")))]
+ // macOS's own voice. The rate is in words a minute (about 175 by
+ // default); -10..10 spans a third of that to three times it, as on Windows.
+ #[cfg(target_os = "macos")]
+ {
+ let words_per_minute = (175.0 * 3f32.powf(self.prefs.tts_rate.clamp(-10, 10) as f32 / 10.0)).round().to_string();
+ if let Err(e) = std::process::Command::new("say").args(["-r", &words_per_minute, "--", &text]).spawn() {
+ self.toast(format!("Couldn't start text-to-speech (say): {e}"), true);
+ }
+ }
+ #[cfg(not(any(windows, target_os = "linux", target_os = "macos")))]
{
let _ = text;
self.toast("Speak Message isn't available on this system yet.", false);
diff --git a/apps/rustcord/src/main.rs b/apps/rustcord/src/main.rs
index a9e5dfc..b90c8c3 100644
--- a/apps/rustcord/src/main.rs
+++ b/apps/rustcord/src/main.rs
@@ -84,18 +84,20 @@ fn main() -> eframe::Result<()> {
let backend = backend::Backend::spawn(demo);
let launch = app::Launch::begin(&backend, demo);
- let options = eframe::NativeOptions {
- viewport: egui::ViewportBuilder::default()
- .with_title(if demo { "RustCord (demo)" } else { "RustCord" })
- // Linux: matches rustcord.desktop, so the dock shows RustCord's icon.
- .with_app_id("rustcord")
- .with_inner_size([1280.0, 800.0])
- .with_min_inner_size([940.0, 560.0])
- // Discord's desktop app draws its own title bar.
- .with_decorations(false)
- .with_icon(app_icon()),
- ..Default::default()
- };
+ let viewport = egui::ViewportBuilder::default()
+ .with_title(if demo { "RustCord (demo)" } else { "RustCord" })
+ // Linux: matches rustcord.desktop, so the dock shows RustCord's icon.
+ .with_app_id("rustcord")
+ .with_inner_size([1280.0, 800.0])
+ .with_min_inner_size([940.0, 560.0])
+ .with_icon(app_icon());
+ // Discord's desktop app draws its own title bar. On macOS it keeps the
+ // window's traffic lights, over the left end of that bar.
+ #[cfg(not(target_os = "macos"))]
+ let viewport = viewport.with_decorations(false);
+ #[cfg(target_os = "macos")]
+ let viewport = viewport.with_fullsize_content_view(true).with_titlebar_shown(false).with_title_shown(false);
+ let options = eframe::NativeOptions { viewport, ..Default::default() };
let result = eframe::run_native(
"RustCord",
diff --git a/apps/rustcord/src/style.rs b/apps/rustcord/src/style.rs
index e97364f..04b97d2 100644
--- a/apps/rustcord/src/style.rs
+++ b/apps/rustcord/src/style.rs
@@ -817,6 +817,14 @@ pub fn install_fonts(ctx: &egui::Context) {
("noto-cjk-arch", "/usr/share/fonts/noto-cjk/NotoSansCJK-Regular.ttc", false),
("noto-cjk-fedora", "/usr/share/fonts/google-noto-sans-cjk-fonts/NotoSansCJK-Regular.ttc", false),
]
+ } else if cfg!(target_os = "macos") {
+ // Symbols, Chinese and Japanese (Hiragino Sans GB has kana too) and
+ // Korean, from the fonts every Mac has.
+ &[
+ ("apple-symbols", "/System/Library/Fonts/Apple Symbols.ttf", false),
+ ("hiragino-sans-gb", "/System/Library/Fonts/Hiragino Sans GB.ttc", false),
+ ("apple-sd-gothic-neo", "/System/Library/Fonts/AppleSDGothicNeo.ttc", false),
+ ]
} else {
&[]
};
diff --git a/apps/rustcord/src/tray.rs b/apps/rustcord/src/tray.rs
index 0ae5582..da7de51 100644
--- a/apps/rustcord/src/tray.rs
+++ b/apps/rustcord/src/tray.rs
@@ -43,8 +43,24 @@ pub fn take_keyboard_focus(_: isize) {}
pub fn set_window_icons(_: isize) {}
#[cfg(not(windows))]
pub fn notify(_: &str, _: &str) {}
-#[cfg(not(windows))]
+#[cfg(not(any(windows, target_os = "macos")))]
pub fn set_badge(_: isize, _: Badge) {}
+
+/// macOS: the badge on RustCord's Dock icon, as Discord's app shows it: the
+/// mention count, or a dot for unread messages.
+#[cfg(target_os = "macos")]
+pub fn set_badge(_: isize, badge: Badge) {
+ use objc2_app_kit::NSApplication;
+ use objc2_foundation::NSString;
+ // The Dock is reached from the main thread, which the UI runs on.
+ let Some(mtm) = objc2::MainThreadMarker::new() else { return };
+ let label = match badge {
+ Badge::None => None,
+ Badge::Dot => Some(NSString::from_str("β€’")),
+ Badge::Count(n) => Some(NSString::from_str(&n.to_string())),
+ };
+ NSApplication::sharedApplication(mtm).dockTile().setBadgeLabel(label.as_deref());
+}
#[cfg(not(windows))]
pub fn system_animations() -> bool {
true
diff --git a/apps/rustcord/src/ui/mod.rs b/apps/rustcord/src/ui/mod.rs
index 88e6339..1d9d40c 100644
--- a/apps/rustcord/src/ui/mod.rs
+++ b/apps/rustcord/src/ui/mod.rs
@@ -110,13 +110,18 @@ impl RustCord {
.show(ctx, |ui| {
let bar = ui.max_rect();
paint_theme_surface(ctx, ui.painter(), bar, 0.0, surface::FRAME, &t);
- // Window buttons.
+ // Window buttons. macOS has the window's own traffic lights,
+ // at the left end instead.
let mut x = bar.right();
+ let own_buttons = if cfg!(target_os = "macos") { 0 } else { 3 };
for (glyph, tip, cmd) in [
(icon::CHROME_CLOSE, "Close", 0),
(if maximized { icon::CHROME_RESTORE } else { icon::CHROME_MAXIMIZE }, if maximized { "Restore" } else { "Maximize" }, 1),
(icon::CHROME_MINIMIZE, "Minimize", 2),
- ] {
+ ]
+ .into_iter()
+ .take(own_buttons)
+ {
let r = Rect::from_min_max(pos2(x - 46.0, bar.top()), pos2(x, bar.bottom()));
x -= 46.0;
let b = ui.interact(r, egui::Id::new(("window_btn", cmd)), Sense::click());
@@ -167,8 +172,10 @@ impl RustCord {
}
}
}
- // Back / forward, far left.
- let mut left = bar.left() + 8.0;
+ // Back / forward, far left (on macOS after the traffic lights,
+ // which full screen hides).
+ let traffic_lights = cfg!(target_os = "macos") && !ctx.input(|i| i.viewport().fullscreen.unwrap_or(false));
+ let mut left = bar.left() + if traffic_lights { 76.0 } else { 8.0 };
let mut nav = None;
if main {
for (glyph, tip, fwd, enabled) in [
@@ -235,9 +242,10 @@ impl RustCord {
self.resize_edges(ctx);
}
- /// Frameless windows need their own resize handles at the edges.
+ /// Frameless windows need their own resize handles at the edges. (macOS
+ /// windows keep their frame, which resizes them.)
fn resize_edges(&self, ctx: &egui::Context) {
- if ctx.input(|i| i.viewport().maximized.unwrap_or(false)) {
+ if cfg!(target_os = "macos") || ctx.input(|i| i.viewport().maximized.unwrap_or(false)) {
return;
}
let Some(p) = ctx.input(|i| i.pointer.hover_pos()) else { return };
diff --git a/packaging/macos/Info.plist b/packaging/macos/Info.plist
new file mode 100644
index 0000000..b128985
--- /dev/null
+++ b/packaging/macos/Info.plist
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<!-- RustCord.app's description; package.sh fills in @VERSION@. The identifier
+ matches the folders RustCord keeps its settings and cache in. -->
+<plist version="1.0">
+<dict>
+ <key>CFBundleName</key>
+ <string>RustCord</string>
+ <key>CFBundleDisplayName</key>
+ <string>RustCord</string>
+ <key>CFBundleIdentifier</key>
+ <string>dev.RustCord.RustCord</string>
+ <key>CFBundleExecutable</key>
+ <string>rustcord</string>
+ <key>CFBundleIconFile</key>
+ <string>RustCord</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundleShortVersionString</key>
+ <string>@VERSION@</string>
+ <key>CFBundleVersion</key>
+ <string>@VERSION@</string>
+ <key>LSMinimumSystemVersion</key>
+ <string>11.0</string>
+ <key>LSApplicationCategoryType</key>
+ <string>public.app-category.social-networking</string>
+ <key>NSHighResolutionCapable</key>
+ <true/>
+ <key>NSSupportsAutomaticGraphicsSwitching</key>
+ <true/>
+ <!-- Without it macOS ends the app the moment a call opens the microphone. -->
+ <key>NSMicrophoneUsageDescription</key>
+ <string>RustCord uses your microphone in voice calls.</string>
+</dict>
+</plist>
diff --git a/packaging/macos/package.sh b/packaging/macos/package.sh
new file mode 100755
index 0000000..3aeb636
--- /dev/null
+++ b/packaging/macos/package.sh
@@ -0,0 +1,52 @@
+#!/bin/sh
+# Makes dist/RustCord-<version>-macos-universal.dmg (RustCord.app for Apple
+# Silicon and Intel Macs, next to a link to Applications) and its .sha256.
+# Run on a Mac from the repository root, after
+# cargo build --release -p rustcord --target aarch64-apple-darwin
+# cargo build --release -p rustcord --target x86_64-apple-darwin
+# or give the two programs: package.sh <arm64 rustcord> <x86_64 rustcord>.
+set -eu
+
+version=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -n 1)
+arm=${1:-target/aarch64-apple-darwin/release/rustcord}
+intel=${2:-target/x86_64-apple-darwin/release/rustcord}
+name="RustCord-$version-macos-universal"
+stage="dist/macos"
+app="$stage/RustCord.app"
+
+rm -rf "$stage"
+mkdir -p "$app/Contents/MacOS" "$app/Contents/Resources"
+lipo -create -output "$app/Contents/MacOS/rustcord" "$arm" "$intel"
+chmod 755 "$app/Contents/MacOS/rustcord"
+sed "s/@VERSION@/$version/g" packaging/macos/Info.plist > "$app/Contents/Info.plist"
+cp LICENSE THIRD_PARTY_NOTICES.md "$app/Contents/Resources/"
+
+# The icon in the sizes the Finder and the Dock ask for, up to the 256 px
+# picture there is.
+iconset="$stage/RustCord.iconset"
+mkdir -p "$iconset"
+for size in 16 32 128 256; do
+ sips -z "$size" "$size" apps/rustcord/assets/icon-256.png --out "$iconset/icon_${size}x${size}.png" >/dev/null
+done
+for size in 16 32 128; do
+ sips -z "$((size * 2))" "$((size * 2))" apps/rustcord/assets/icon-256.png --out "$iconset/icon_${size}x${size}@2x.png" >/dev/null
+done
+iconutil -c icns "$iconset" -o "$app/Contents/Resources/RustCord.icns"
+rm -rf "$iconset"
+
+# Signed ad hoc (Apple Silicon runs nothing unsigned), not with a Developer
+# ID: the first start needs "Open Anyway", see the README.
+codesign --force --sign - "$app"
+
+ln -s /Applications "$stage/Applications"
+rm -f "dist/$name.dmg"
+# hdiutil now and then finds the disk image busy on GitHub's Macs: try again.
+for attempt in 1 2 3; do
+ hdiutil create -volname RustCord -srcfolder "$stage" -fs HFS+ -format UDZO "dist/$name.dmg" >/dev/null && break
+ echo "hdiutil failed (attempt $attempt), trying again"
+ sleep 10
+done
+[ -f "dist/$name.dmg" ]
+(cd dist && shasum -a 256 "$name.dmg" > "$name.dmg.sha256")
+rm -rf "$stage"
+echo "dist/$name.dmg"
diff --git a/packaging/macos/smoke-test.sh b/packaging/macos/smoke-test.sh
new file mode 100755
index 0000000..d0f8033
--- /dev/null
+++ b/packaging/macos/smoke-test.sh
@@ -0,0 +1,38 @@
+#!/bin/sh
+# Installs RustCord from the .dmg as someone would and starts it twice: signed
+# out (Discord's login page in the window) and in demo mode. A screenshot and
+# the log of each go to dist/smoke. Fails if RustCord quits or panics.
+# Run on a Mac from the repository root, after package.sh.
+set -eu
+
+dmg=$(ls dist/RustCord-*-macos-universal.dmg | head -n 1)
+out=dist/smoke
+mount=$(mktemp -d)
+mkdir -p "$out"
+
+plutil -lint packaging/macos/Info.plist
+hdiutil attach "$dmg" -nobrowse -readonly -mountpoint "$mount" >/dev/null
+rm -rf /Applications/RustCord.app
+cp -R "$mount/RustCord.app" /Applications/
+hdiutil detach "$mount" >/dev/null
+codesign --verify --strict --verbose=1 /Applications/RustCord.app
+echo "architectures: $(lipo -archs /Applications/RustCord.app/Contents/MacOS/rustcord)"
+
+# start <name> [flag]: run RustCord for 30 seconds, then screenshot and stop it.
+start() {
+ /Applications/RustCord.app/Contents/MacOS/rustcord ${2:-} >"$out/$1.log" 2>&1 &
+ pid=$!
+ sleep 30
+ screencapture -x "$out/$1.png" || echo "no screenshot for $1"
+ if ! kill -0 "$pid" 2>/dev/null || grep -q "panicked" "$out/$1.log"; then
+ echo "RustCord ($1) quit or panicked:"
+ tail -n 60 "$out/$1.log"
+ return 1
+ fi
+ ps -o rss=,%cpu= -p "$pid" | awk -v name="$1" '{ printf "%s: %d MB resident, %s%% CPU\n", name, $1 / 1024, $2 }'
+ kill "$pid"
+ wait "$pid" || true
+}
+
+start login
+start demo --demo