Skip to content

Commit 2ba8856

Browse files
authored
fix(core): docs.rs build failing for macOS (#8095)
1 parent f964cbd commit 2ba8856

File tree

4 files changed

+65
-47
lines changed

4 files changed

+65
-47
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"tauri": patch:bug
3+
---
4+
5+
Fix docs.rs build for `x86_64-apple-darwin`.

core/tauri/Cargo.toml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ no-default-features = true
1717
features = [
1818
"wry",
1919
"custom-protocol",
20-
"api-all",
2120
"windows7-compat",
2221
"cli",
2322
"updater",
@@ -27,7 +26,16 @@ features = [
2726
"http-multipart",
2827
"icon-png",
2928
"test",
30-
"dox"
29+
"dox",
30+
"dialog",
31+
"global-shortcut",
32+
"http-request",
33+
"os-api",
34+
"process-relaunch",
35+
"process-exit",
36+
"protocol-asset",
37+
"process-command-api",
38+
"shell-open",
3139
]
3240
rustdoc-args = [ "--cfg", "doc_cfg" ]
3341
default-target = "x86_64-unknown-linux-gnu"

core/tauri/src/api/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pub mod cli;
3131
#[cfg_attr(doc_cfg, doc(cfg(feature = "cli")))]
3232
pub use clap;
3333

34-
#[cfg(all(desktop, feature = "notification"))]
34+
#[cfg(all(desktop, any(feature = "notification", feature = "dox")))]
3535
#[cfg_attr(doc_cfg, doc(cfg(all(desktop, feature = "notification"))))]
3636
pub mod notification;
3737

core/tauri/src/api/notification.rs

Lines changed: 49 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -153,55 +153,60 @@ impl Notification {
153153
deprecated = "This function does not work on Windows 7. Use `Self::notify` instead."
154154
)]
155155
pub fn show(self) -> crate::api::Result<()> {
156-
let mut notification = notify_rust::Notification::new();
157-
if let Some(body) = self.body {
158-
notification.body(&body);
159-
}
160-
if let Some(title) = self.title {
161-
notification.summary(&title);
162-
}
163-
if let Some(icon) = self.icon {
164-
notification.icon(&icon);
165-
} else {
166-
notification.auto_icon();
167-
}
168-
if let Some(sound) = self.sound {
169-
notification.sound_name(&match sound {
170-
#[cfg(target_os = "macos")]
171-
Sound::Default => "NSUserNotificationDefaultSoundName".to_string(),
172-
#[cfg(windows)]
173-
Sound::Default => "Default".to_string(),
174-
#[cfg(all(unix, not(target_os = "macos")))]
175-
Sound::Default => "message-new-instant".to_string(),
176-
Sound::Custom(c) => c,
177-
});
178-
}
179-
#[cfg(windows)]
156+
#[cfg(feature = "dox")]
157+
return Ok(());
158+
#[cfg(not(feature = "dox"))]
180159
{
181-
let exe = tauri_utils::platform::current_exe()?;
182-
let exe_dir = exe.parent().expect("failed to get exe directory");
183-
let curr_dir = exe_dir.display().to_string();
184-
// set the notification's System.AppUserModel.ID only when running the installed app
185-
if !(curr_dir.ends_with(format!("{SEP}target{SEP}debug").as_str())
186-
|| curr_dir.ends_with(format!("{SEP}target{SEP}release").as_str()))
187-
{
188-
notification.app_id(&self.identifier);
160+
let mut notification = notify_rust::Notification::new();
161+
if let Some(body) = self.body {
162+
notification.body(&body);
189163
}
190-
}
191-
#[cfg(target_os = "macos")]
192-
{
193-
let _ = notify_rust::set_application(if cfg!(feature = "custom-protocol") {
194-
&self.identifier
164+
if let Some(title) = self.title {
165+
notification.summary(&title);
166+
}
167+
if let Some(icon) = self.icon {
168+
notification.icon(&icon);
195169
} else {
196-
"com.apple.Terminal"
197-
});
198-
}
170+
notification.auto_icon();
171+
}
172+
if let Some(sound) = self.sound {
173+
notification.sound_name(&match sound {
174+
#[cfg(target_os = "macos")]
175+
Sound::Default => "NSUserNotificationDefaultSoundName".to_string(),
176+
#[cfg(windows)]
177+
Sound::Default => "Default".to_string(),
178+
#[cfg(all(unix, not(target_os = "macos")))]
179+
Sound::Default => "message-new-instant".to_string(),
180+
Sound::Custom(c) => c,
181+
});
182+
}
183+
#[cfg(windows)]
184+
{
185+
let exe = tauri_utils::platform::current_exe()?;
186+
let exe_dir = exe.parent().expect("failed to get exe directory");
187+
let curr_dir = exe_dir.display().to_string();
188+
// set the notification's System.AppUserModel.ID only when running the installed app
189+
if !(curr_dir.ends_with(format!("{SEP}target{SEP}debug").as_str())
190+
|| curr_dir.ends_with(format!("{SEP}target{SEP}release").as_str()))
191+
{
192+
notification.app_id(&self.identifier);
193+
}
194+
}
195+
#[cfg(target_os = "macos")]
196+
{
197+
let _ = notify_rust::set_application(if cfg!(feature = "custom-protocol") {
198+
&self.identifier
199+
} else {
200+
"com.apple.Terminal"
201+
});
202+
}
199203

200-
crate::async_runtime::spawn(async move {
201-
let _ = notification.show();
202-
});
204+
crate::async_runtime::spawn(async move {
205+
let _ = notification.show();
206+
});
203207

204-
Ok(())
208+
Ok(())
209+
}
205210
}
206211

207212
/// Shows the notification. This API is similar to [`Self::show`], but it also works on Windows 7.

0 commit comments

Comments
 (0)