diff --git a/Cargo.toml b/Cargo.toml
index f5474ae4e37e..28cc25cc1598 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -16,6 +16,10 @@ crate-type = ["cdylib", "staticlib", "rlib"]
name = "naming"
path = "src/naming.rs"
+[[bin]]
+name = "service"
+path = "src/service.rs"
+
[features]
inline = []
cli = []
diff --git a/build.py b/build.py
index dc85a60059df..87c0dbd3432d 100755
--- a/build.py
+++ b/build.py
@@ -405,12 +405,13 @@ def build_flutter_dmg(version, features):
if not skip_cargo:
# set minimum osx build target, now is 10.14, which is the same as the flutter xcode project
system2(
- f'MACOSX_DEPLOYMENT_TARGET=10.14 cargo build --features {features} --lib --release')
+ f'MACOSX_DEPLOYMENT_TARGET=10.14 cargo build --features {features} --release')
# copy dylib
system2(
"cp target/release/liblibrustdesk.dylib target/release/librustdesk.dylib")
os.chdir('flutter')
system2('flutter build macos --release')
+ system2('cp -rf ../target/release/service ./build/macos/Build/Products/Release/RustDesk.app/Contents/MacOS/')
'''
system2(
"create-dmg --volname \"RustDesk Installer\" --window-pos 200 120 --window-size 800 400 --icon-size 100 --app-drop-link 600 185 --icon RustDesk.app 200 190 --hide-extension RustDesk.app rustdesk.dmg ./build/macos/Build/Products/Release/RustDesk.app")
diff --git a/flutter/macos/Podfile.lock b/flutter/macos/Podfile.lock
index a29674fece3e..a9f3c7388cfb 100644
--- a/flutter/macos/Podfile.lock
+++ b/flutter/macos/Podfile.lock
@@ -95,17 +95,17 @@ SPEC CHECKSUMS:
desktop_drop: 69eeff437544aa619c8db7f4481b3a65f7696898
desktop_multi_window: 566489c048b501134f9d7fb6a2354c60a9126486
device_info_plus: 5401765fde0b8d062a2f8eb65510fb17e77cf07f
- file_selector_macos: 54fdab7caa3ac3fc43c9fac4d7d8d231277f8cf2
+ file_selector_macos: 468fb6b81fac7c0e88d71317f3eec34c3b008ff9
flutter_custom_cursor: 629957115075c672287bd0fa979d863ccf6024f7
FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24
package_info_plus: 02d7a575e80f194102bef286361c6c326e4c29ce
- path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46
+ path_provider_foundation: 3784922295ac71e43754bd15e0653ccfd36a147c
screen_retriever: 59634572a57080243dd1bf715e55b6c54f241a38
sqflite: 673a0e54cc04b7d6dba8d24fb8095b31c3a99eec
texture_rgba_renderer: cbed959a3c127122194a364e14b8577bd62dc8f2
uni_links_desktop: 45900fb319df48fcdea2df0756e9c2626696b026
- url_launcher_macos: 5f437abeda8c85500ceb03f5c1938a8c5a705399
- video_player_avfoundation: 7c6c11d8470e1675df7397027218274b6d2360b3
+ url_launcher_macos: d2691c7dd33ed713bf3544850a623080ec693d95
+ video_player_avfoundation: 02011213dab73ae3687df27ce441fbbcc82b5579
wakelock_plus: 4783562c9a43d209c458cb9b30692134af456269
window_manager: 3a1844359a6295ab1e47659b1a777e36773cd6e8
window_size: 339dafa0b27a95a62a843042038fa6c3c48de195
diff --git a/flutter/macos/Runner/AppDelegate.swift b/flutter/macos/Runner/AppDelegate.swift
index 3498decd37a5..46372a5822fc 100644
--- a/flutter/macos/Runner/AppDelegate.swift
+++ b/flutter/macos/Runner/AppDelegate.swift
@@ -1,7 +1,7 @@
import Cocoa
import FlutterMacOS
-@NSApplicationMain
+@main
class AppDelegate: FlutterAppDelegate {
var launched = false;
override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
diff --git a/src/platform/macos.rs b/src/platform/macos.rs
index d030bc6f1363..2fb2b46db90a 100644
--- a/src/platform/macos.rs
+++ b/src/platform/macos.rs
@@ -515,53 +515,6 @@ pub fn lock_screen() {
pub fn start_os_service() {
log::info!("Username: {}", crate::username());
- let mut sys = System::new();
- let path =
- std::fs::canonicalize(std::env::current_exe().unwrap_or_default()).unwrap_or_default();
- let mut server = get_server_start_time(&mut sys, &path);
- if server.is_none() {
- log::error!("Agent not started yet, please restart --server first to make delegate work",);
- std::process::exit(-1);
- }
- let my_start_time = sys
- .process((std::process::id() as usize).into())
- .map(|p| p.start_time())
- .unwrap_or_default() as i64;
- log::info!("Startime: {my_start_time} vs {:?}", server);
-
- std::thread::spawn(move || loop {
- std::thread::sleep(std::time::Duration::from_secs(1));
- if server.is_none() {
- server = get_server_start_time(&mut sys, &path);
- }
- let Some((start_time, pid)) = server else {
- log::error!(
- "Agent not started yet, please restart --server first to make delegate work",
- );
- std::process::exit(-1);
- };
- if my_start_time <= start_time + 3 {
- log::error!(
- "Agent start later, {my_start_time} vs {start_time}, please start --server first to make delegate work, earlier more 3 seconds",
- );
- std::process::exit(-1);
- }
- // only refresh this pid and check if valid, no need to refresh all processes since refreshing all is expensive, about 10ms on my machine
- if !sys.refresh_process_specifics(pid, ProcessRefreshKind::new()) {
- server = None;
- continue;
- }
- if let Some(p) = sys.process(pid.into()) {
- if let Some(p) = get_server_start_time_of(p, &path) {
- server = Some((p, pid));
- } else {
- server = None;
- }
- } else {
- server = None;
- }
- });
-
if let Err(err) = crate::ipc::start("_service") {
log::error!("Failed to start ipc_service: {}", err);
}
diff --git a/src/platform/privileges_scripts/daemon.plist b/src/platform/privileges_scripts/daemon.plist
index 61efc25eca4c..59f103a31385 100644
--- a/src/platform/privileges_scripts/daemon.plist
+++ b/src/platform/privileges_scripts/daemon.plist
@@ -12,7 +12,7 @@
/bin/sh
-c
- sleep 3; if pgrep -f '/Applications/RustDesk.app/Contents/MacOS/RustDesk --server' > /dev/null; then /Applications/RustDesk.app/Contents/MacOS/RustDesk --service; fi
+ /Applications/RustDesk.app/Contents/MacOS/service
RunAtLoad