-
i have an app using sparkle in production (thanks so much by the way!), and i have a need to occasionally programmatically quit and restart the app not connected to an update. i'm sure the most obvious response to that need is to tell me "don't do that, there must be a better way" -- but i think i have a very compelling use case, and can describe it if necessary. anyway, i was researching how to do this because i thought to myself "sparkle does it, it must be possible". i was hoping there were built-in apple API's i could just call to re-launch, but that doesn't seem to be the case. from the research i did, it seems like spawning or reaching out to some linked executable in the app bundle is necessary, which is (i think) what sparkle does. which got me thinking. sparkle can do this, and my app already embeds sparkle, so is there any way i can leverage sparkle to quit and relaunch at a time other than during an update? ideally, is there a swift function i can call to do this? do you guys expose such a method? or if there is no simple api, is there a path for me to reach out to your embedded/linked executables to mimic how you guys quit and relaunch? would greatly appreciate any insight. thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
No Sparkle will not be able to help you here. There’s nothing convenient. |
Beta Was this translation helpful? Give feedback.
-
@zorgiepoo thanks for the response. is there anything inconvenient you could point me to? or could you give me at least a high-level description of how Sparkle accomplishes the relaunch? i'm impressed with the feature you guys have, and curious how you pulled it off with such stability. and like i said, i feel like my use-case is pretty compelling, so i'm going to try to replicate it one way or another -- so i'd love to learn from the battle-hardened, real-world tested implementation you guys have. i don't know objective-c, so it's a bit tough for me to follow the thread in the source code (i have tried), which is why even just a high-level description would be really helpful. thanks so much! |
Beta Was this translation helpful? Give feedback.
The approach I'd use that is similar to Sparkle is including a command line utility in your app which you spawn a task for. It waits until your application(s) with a matching pid or bundle id has terminated. While that happens your app can try to terminate your app ([NSApp terminate:]). When your command line tool sees the app has terminated, it can launch your application (you can use NSWorkspace/NSRunningApplication for this both for observing termination and launching an app). If the user cancels your app quit request (eg. unsaved open document) you can terminate this task, although I am not sure if there is any way to detect that (if you don't want the app termination to be cancellabl…