Post

Replies

Boosts

Views

Activity

MacOS Application as a daemon or in non-interaction mode
We are building a 'server' application that can either run as a daemon or can run in background without showing any GUI. Basically, the end user can either configure this to run as a daemon so that it can be tied to the user's session or will launch the process which user will start and quit as needed. I wanted to understand what is the recommended mechanism for such an application from Apple - Should this application be built as a macOS Bundle ? Apple documentation also says that we should not daemonize the process by calling fork. Hence if we create a unix-style executable, will I not need to fork to make it run in a detached state when I launch the executable via double-click ? [Reference Link] Is it fine to have an application on macOS which is a bundle but does not show any UI when launched by double click on the app-icon or via 'open'? While we have been able to achieve this by using NSApplicationMain and not showing the UI, was wondering if using CFRunLoop is best for this case as it is a non-gui application. If we can get the right documentation link or recommendations on how we should build such an application which can run in a non-gui mode and also in a daemonized manner, it will help us. Should the application be always built as a macos bundle or should it be a unix-style executable to support both the cases - by the same application/product and how should we look at the distribution of such applications.
4
1
516
Mar ’25
iOS Simulator gives 'You dont have permission error'
I am currently on macOS Monterey 12.2 and have started an iPhone 12 iOS 15.0 simulator. On this simulator, if I drop files from desktop or a folder inside desktop, I get an error saying, 'The file could not be opened because you don't have the permission to view it'. However, if this files is moved to some folder inside ~/Builds/SampleFiles/*, the drag and drop copies the files to the simulator. Is something specific needed to be done to provide such an access to the simulator ? I can see that Simulator has 'Full Disk Access' under 'Security and Privacy'.
2
0
3.4k
Aug ’22
Running an application as a Daemon
I am building a macOS application and would like to check if the application is running in the background or not. Was referring documentation for the same and found few links under 'Archives'. Below is the document I could get: https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/DesigningDaemons.html Is there some latest documentation available on this subject ? Any pointers would be helpful. Thanks in advance.
1
0
907
May ’21
How can we open and use a terminal using Objective-C
Hi, We are creating a macOS application that is built as a 'Bundle' and NOT as a Unix-style application. In a specific flow, we need to attach this process to a terminal session by creating one. Now, on this attached terminal, stdin/stdout etc would happen. We are using Objective C. Any pointers on how to go about this would be helpful.
1
0
1.4k
Dec ’21
Can iOS extension use the same binary as app?
I have an iOS SwiftUI app which uses some extensions like NotificationServiceExtension, NotificationContentExtension, WidgetExtension etc. I noticed that each extension uses its own process and has its own bundle with the .appex extension... and is packaged within the app bundle, with .app extension. In my case, most of my logic is in C++ and when the app starts up, it needs to 'startup' the C++ layer. Now, in WidgetExtension, if it's going to read data from disk and update its interface, I need to initialise my C++ layer first. The same can be said for NotificationServiceExtension. This is leading me to include all my C++ artefacts into the extension target as well. Here's my problem: If the size of my app (containing all my C++ artefacts) is 10MB and I'm using 20 extensions (say), the final size of the shipped app bundle is 10MB + (20 * 10MB) = 210MB, since extension bundle (.appex) is packaged within the app bundle (.app). Since the app and the extensions are using the same C++ artefacts, I was hoping to have one binary in the bundle. The app and its extensions will point to this binary. When the app is launched, the app entry point (struct conforming to App protocol) is invoked, in case of widget, the widget entry point (WidgetBundle) is invoked and so on for each extension. This will reduce the final size of the app bundle. Is it possible to have one binary and the app target, all extension targets would use this binary for there functioning?
1
0
743
May ’24
Launching the application as a daemon
I am writing an application which is capable of running as a regular application – with a GUI, AND as a ‘daemon’ – servicing other GUI based applets. The user is expected to decide in which mode they want to run the application. The questions are: Can this be done? On Windows, I am able to do this by allowing user to ‘install as a service’ and I can programmatically check if the application HAS been started as a service or not – and take the appropriate code path. What is the equivalent in MacOS? On startup, how do I check if the application is being launched in regular mode, or launched as a daemon What are the system interactions which I need to specifically hook into if it is launched as a daemon.
0
0
511
May ’21
'open -ja <app_name>' command not launching the application as hidden
There is an 'open' command in mac with some options as: -g  Do not bring the application to the foreground. -j  Launches the app hidden. While it claims to launch the application hidden and/or in the background – it always seems to behave the same way.  Is there some ‘input’ the application is supposed to receive and behave suitably (that is, not show a UI if it is opened in such a mode)?  How do I access this intent of the user? Thanks !
0
0
474
May ’21
CFUserNotificationDisplayAlert not showing alert window in macOS BigSur
I am intending to show an alert message in macOS through a C++ based application. I am using CFUserNotificationDisplayAlert for the same. Below is the piece of code that I have used to display the alert window which I have written in the .mm file: CFOptionFlags cfRes; CFUserNotificationDisplayAlert(0, kCFUserNotificationCautionAlertLevel, NULL, NULL, NULL, CFSTR("Message Header"), CFSTR("Message Body"), CFSTR("Ok"), NULL, NULL, &cfRes); The above works fine on Catalina but does not show the alert window in BigSur. Is there anything I am missing ?
0
0
558
Jun ’21
Issue with CFUserNotificationDisplayAlert on macOS BigSur
I am intending to show an alert message in macOS through a C++ based application. I am using CFUserNotificationDisplayAlert for the same. Below is the piece of code that I have used to display the alert window which I have written in the .mm file: CFOptionFlags cfRes; CFUserNotificationDisplayAlert(0, kCFUserNotificationCautionAlertLevel, NULL, NULL, NULL, CFSTR("Message Header"), CFSTR("Message Body"), CFSTR("Ok"), NULL, NULL, &cfRes); The above works fine on Catalina but does not show the alert window in BigSur. Is there anything I am missing ?
0
0
535
Jun ’21
Having multiple sessions on Mac with same user
Hi, I have a shared Mac system running on BigSur 11.4 - which I access from office and home. I have a single user id, and do not want the two sessions to interfere with each other. Can I have 2 independent sessions on this Mac machine for the same user ? Basically, I am seeking guidance on ‘what kind of options/settings/helper applications' will allow me to do this. Thanks in advance.
0
0
882
Dec ’21
Difference between open --hide and open --background
Hi, I am trying to use the open command from the Terminal window to open my application. I have tried the following : open --hide MyApp.app open --background MyApp.app The documentation says : --help launch the app hidden and --background does not bring the application to the foreground. I would like to understand the difference between the two ? What I have observed is, in both cases the application launches and my GUI Window is not in the foreground. Am I missing something ?
0
0
549
Dec ’21
How to detach application process from the parent console/terminal ?
I have an application that is built as an app bundle. I open a new terminal window, and launch the application through ./. When I do this, the application UI is launched and some application logs are printed on the terminal. If I want to detach my application process from the terminal, how can the same be achieved such that I can close the terminal and my application keeps running. Basically, how do we ‘detach’ from the parent console once we have detected that we WERE started from the parent console ?
0
0
925
Jan ’22
Programmatically access all desktops/workspaces in macOS
Hi, I would like to be able to tell at any time which mission control workspace the user is currently using programmatically on macOS or programmatically check the number of desktops/workspaces are currently created on a macOS screen. I could not find any working answer during my search. Any workspace identifier works for me (uuid, workspace number...). Is there a programmatic way of doing this in Objective C ? Thank you for the help!
0
0
650
Jan ’22