Service Management

RSS for tag

The Service Management framework provides facilities to load and unload launchd services and read and modify launchd dictionaries from within an application.

Service Management Documentation

Pinned Posts

Posts under Service Management tag

63 Posts
Sort by:
Post not yet marked as solved
3 Replies
47 Views
I'm busy designing my app's functionality and really would like to provide some features that rely on background processing after the user has logged in. A Login Item seems ideal for this use case. I appreciate the lengths Apple go to, to communicate the complex technologies involved in app development, including the planning of macOS apps. I haven't found any information in the planning and design (admittedly under HIGs) documentation on whether it's possible to provide some background processing element along with an app destined for the Mac App Store. Perhaps it's not mentioned for a reason? However, it would be really useful to background processing dealt with up-front, especially under planning, because it has a huge impact on how one moves forward with product design. Especially when you're an indy developer with limited time and resources. I can't, for the life of me, find where I previously read that daemons and agents weren't allowed to be shipped with a Mac App Store app, because of the Sandbox requirements. It was probably a reply by Eskimo somewhere in the forums. Does the same apply to Login Items? The bulk of the Login Item documentation is in the documentation archive, most of which was written before the existence of the app stores, so I couldn't find any answers there. I previously believed that an app destined for the Mac App Store could only include a single binary, that of the main app itself. Although I've seen the recent article on including a command line utility binary in the distribution too. Also, if my understanding of code signing is correct, apps distributed via an app store are signed by Apple, and thus can't communicate via XPC with a binary signed and distributed via a Developer ID. Or is there some workaround there that might get me closer to my goal?
Posted Last updated
.
Post not yet marked as solved
1 Replies
42 Views
I am attempting to install and utilize an agent using the new(ish) SMAppService API with an existing app. The agent appears to install (no error is returned), but when I try to start the agent from Terminal, I get the following in the launchd.log: 2024-04-22 09:57:27.469039 (gui/502/com.redacted.service.agent) : internal event: WILL_SPAWN, code = 0 2024-04-22 09:57:27.469080 (gui/502/com.redacted.service.agent) : service state: spawn scheduled 2024-04-22 09:57:27.469081 (gui/502/com.redacted.service.agent) : service state: spawning 2024-04-22 09:57:27.469100 (gui/502/com.redacted.service.agent) : launching: one-shot 2024-04-22 09:57:27.469105 (gui/502/com.redacted.service.agent) : Allowing non-reentrant proxy for resolving path 2024-04-22 09:57:27.469947 (gui/502/com.redacted.service.agent [71866]) : xpcproxy spawned with pid 71866 2024-04-22 09:57:27.469960 (gui/502/com.redacted.service.agent [71866]) : internal event: SPAWNED, code = 0 2024-04-22 09:57:27.469964 (gui/502/com.redacted.service.agent [71866]) : service state: xpcproxy 2024-04-22 09:57:27.469997 (gui/502/com.redacted.service.agent [71866]) : internal event: SOURCE_ATTACH, code = 0 2024-04-22 09:57:27.506283 (gui/502/com.redacted.service.agent [71866]) : Service could not initialize: posix_spawn(/Users/chrisf/Library/Developer/Xcode/DerivedData/Redacted-gttupgdyakodzddurpavhmscwabs/Build/Products/Debug/Redacted App.app/Contents/MacOS/Service Agent.app), error 0xd - Permission denied 2024-04-22 09:57:27.506306 (gui/502/com.redacted.service.agent [71866]) : initialization failure: 23E224: xpcproxy + 31420 [1098][A7EF179C-FBCC-349E-A7D2-09B2F1408413]: 0xd 2024-04-22 09:57:27.506309 (gui/502/com.redacted.service.agent [71866]) : internal event: INIT, code = 13 2024-04-22 09:57:27.506313 (gui/502/com.redacted.service.agent [71866]) : job state = spawn failed 2024-04-22 09:57:27.507148 (gui/502/com.redacted.service.agent [71866]) : xpcproxy exited due to exit(78) 2024-04-22 09:57:27.507153 (gui/502/com.redacted.service.agent [71866]) : exited due to exit(78) 2024-04-22 09:57:27.507162 (gui/502/com.redacted.service.agent [71866]) : already handled failed init, ignoring 2024-04-22 09:57:27.507170 (gui/502/com.redacted.service.agent [71866]) : service state: exited 2024-04-22 09:57:27.507186 (gui/502/com.redacted.service.agent [71866]) : internal event: EXITED, code = 0 (tldr: error 0xd - Permission denied) I'd also be curious how we are expected to launch agents once registered with SMAppService. Is it sufficient simply to make an XPC call to an exposed method? Thanks!
Posted Last updated
.
Post marked as solved
1 Replies
126 Views
I'm a bit confuse on the file permission between root and admin account. I'm developing the background user agent process, and I created the agent plist file with the permission R&W for my admin account. When I tried to load my agent process with launchd, it said the plist file permission is not right. Only after I change the plist file owner to root chown root my.plist, did everything work. From the above situation, it seems that the root user cannot access files that are only authorized to the admin user. Admin account also can't access files authorized only to root, unless you add sudo or enter the password when the request admin password box pops up. But by sudo or password, it just temporarily converts your account from admin to root account. So am I right in my speculation?
Posted
by Ere0n.
Last updated
.
Post not yet marked as solved
2 Replies
196 Views
1、 my plist /Library/LaunchAgents/com.vivi.control.serviceAgent.plist like this: <?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"> <plist version="1.0"> <dict> <key>Label</key> <string>com.vivi.control.serviceAgent</string> <key>ProgramArguments</key> <array> <string>/Users/yuellppa/Downloads/vivo_test</string> </array> <key>RunAtLoad</key> <true/> </dict> </plist> when the label is other any name but not "com.vivi.control.serviceAgent", use launchctl load /Library/LaunchAgents/com.vivi.control.serviceAgent.plist and launchctl unload /Library/LaunchAgents/com.vivi.control.serviceAgent.plist is ok. when label is "com.vivi.control.serviceAgent", launchctl load or launchctl unload get error 5: Input/output error. use launchctl list | grep com.vivi.control.serviceAgent get nothing, so has no conflicting service。 Can anyone help me take a look?
Posted
by yuelppa.
Last updated
.
Post not yet marked as solved
1 Replies
208 Views
I am having a bundled application(.app file) and I am wanting to run this application via ssh session which does not have GUI access. Launching this application in a desktop GUI session, runs the application perfectly. However, on running it on the same machine via ssh session produces an error. Note: My application does not bring up any GUI window(it' just produces some logs on the terminal), so running it in a non-GUI environment should have worked. I get the below error when trying to launch the unix exe in the .app bundle( ./Myapp.app/Contents/MacOS/Myapp ) on the terminal. I have observed that applicationDidFinishLaunching(_:) gets called and then the below error occurs. +[NSXPCSharedListener endpointForReply:withListenerName:replyErrorCode:]: an error occurred while attempting to obtain endpoint for listener 'ClientCallsAuxiliary': Connection interrupted I tried running other bundled applications via ssh, but all seems to produce the same error. Can someone confirm Is running bundled application in a non GUI session not allowed by Apple. If its allowed, how can I solve this? Even running the .app file using the open command fails to launch the application, although it produces a different error which is consistent across different applications.
Posted Last updated
.
Post not yet marked as solved
8 Replies
368 Views
We have a test scenario where we install our app package on a Mac setup using MDM (Jamf). Below are the test steps and observation: This installation is done on this Mac with no user logged in. Installation is completed successfully. Now when an user log in on this mac machine, the expectation is that the app bundle will be started by the launchd (RunAtLoad). But the app is not started. When I check console logs I could see few logs around the app but from those logs I couldn't figure out why the app didn't start. I rebooted my test machine but that also didnt start my app. My app is not listed in 'launchctl list' command. My App bundle contains container app and a packet tunnel extension. Below is how my plist file looks like in '/Library/LaunchAgents/com.****.***ui.plist': { KeepAlive = 1; Label = "com.*****.client.****ui"; LimitLoadToSessionType = ( Aqua ); ProgramArguments = ( "/Applications/*********.app/Contents/MacOS/****Module" ); RunAtLoad = 1; SuccessfulExit = 1; Version = "110.200.0.100"; } In Console below are the last set of log which I could find related to my app: support_log.txt In above logs below statement mentions the extn which is related to my app bundle: 2024-03-19 15:48:55.256020+0530 0x462 Default 0x0 206 0 symptomsd: (SymptomEvaluator) [com.apple.symptomsd:analytics] [Skipping first 85 of 95 entries] 2024-03-19 15:48:55.256051+0530 0x462 Default 0x0 206 0 symptomsd: (SymptomEvaluator) [com.apple.symptomsd:analytics] entry: Thu Feb 8 20:48:26 2024 NetworkExtension.com.*****.client.*****-Client.*****ui.*****pkttunnel.104.2.12.191.104.2.12 (bundle) 0 0 0 0 0 0 Can someone please help me in understanding what could be wrong here, why would 'RunAtLoad' key word wont work here to start my app on user login or reboot? Note: Everything work fine when my app is installed with an user logged in to the test machine. Also App starts successfully if I run command 'lauchctl bootstrap gui/ /Library/LaunchAgents/com.****.****ui.plist' in the above mentioned test scenario where app didnt auto start by launchd: 'RunAtLoad'.
Posted
by macnd.
Last updated
.
Post not yet marked as solved
2 Replies
167 Views
Hi we are developing a launchDeamon application and need to be notified when a new session is initiated or when a user connects to the Mac We looked into the Notifications in Cocoa and the Security framework and couldn't get a precise number is there any way to detect the ammount of users/sessions currently active?
Posted
by orenc17.
Last updated
.
Post not yet marked as solved
1 Replies
657 Views
I am implementing parental control app via python 3.9 for macOS. Therefore I want to use launch agent to keep my application always alive (app reopened automatically after reboot pc and protected against to be closed via activity monitor.) I want to give keep alive enabling and disabling option to parents that they can deactivate or activate it in the app GUI. I achieved to keep alive my app standalone signed app without sandboxing(or via Terminal command) but if I sign it with sandbox then I get following error for "launchctl load" and "launchctl bootstrap" commands which are executed in the application "Load failed: 5: Input/output error" My steps without Sandbox which works fine: 1- Create a com.test_gui.macos.plist file under /Library/LaunchAgents with following content: `<?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"> <plist version="1.0"> <dict> <key>KeepAlive</key> <true/> <key>Label</key> <string>test_gui</string> <key>ProgramArguments</key> <array> <string>open</string> <string>-g</string> <string>-a</string> <string>/Applications/test_gui.app</string> </array> </dict> </plist>` 2- create a python file for launch agent activation (I know either launchctl load or bootstrap should be used but I used both of them to test both.): import subprocess cmd = "launchctl enable gui/501/test_gui" response = subprocess.call(cmd, shell=True) time.sleep(2) cmd = "launchctl load -w /Library/LaunchAgents/com.test_gui.macos.plist" response = subprocess.call(cmd, shell=True) time.sleep(2) cmd = "launchctl bootstrap system /Library/LaunchAgents/com.test_gui.macos.plist" response = subprocess.call(cmd, shell=True) time.sleep(50) 3- Create standalone app via nutika: python3.9 -m nuitka --run --standalone --macos-disable-console --macos-create-app-bundle \--macos-app-mode=ui-element --enable-plugin=pyside6 --macos-app-icon=/Users/emre/Documents/MrProtect/icons/app_icon.png \--include-data-dir=icons=icons test_gui.py 4-Create a .sh file to sign app without sandboxing: #!/bin/sh APP_PATH="/Users/emre/Documents/tests/Deployment/test_gui.app" SIGNING_IDENTITY_APP="Apple Development: Emre Guenay (***)" PASSWORD="***" codesign -s "$SIGNING_IDENTITY_APP" -f \ "$APP_PATH/Contents/MacOS/Python" codesign -s "$SIGNING_IDENTITY_APP" -f \ "$APP_PATH/Contents/MacOS/test_gui" exit 0 5-execute sh file and see following output: /Users/emre/Documents/MrProtect/tests/Deployment/test_gui.app/Contents/MacOS/Python: replacing existing signature /Users/emre/Documents/MrProtect/tests/Deployment/test_gui.app/Contents/MacOS/test_gui: replacing existing signature 6-copy paste signed standalone app(without sandbox) file under /Applications/ 7-execute app and try to close app via activity monitor and observe that the app is reopened automatically. so the launch agent works fine Failed Steps(Sign the same app with sandbox and observe that both launchctl load and bootstrap returns "Load failed: 5: Input/output error") 8- create an app.entitlements file with following content: \<?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"\> \<plist version="1.0"\> \<dict\> \<key\>com.apple.security.app-sandbox\</key\> \<true/\> \</dict\> \</plist\> 9-Create a .sh file to sign app with sandboxing: #!/bin/sh # APP_PATH="/Users/emre/Documents/tests/Deployment/test_gui.app" SIGNING_IDENTITY_APP="Apple Development: Emre Guenay (***)" PASSWORD="***" codesign -s "$SIGNING_IDENTITY_APP" -f \ \--entitlements app.entitlements \ "$APP_PATH/Contents/MacOS/Python" codesign -s "$SIGNING_IDENTITY_APP" -f \ \--entitlements app.entitlements \ "$APP_PATH/Contents/MacOS/test_gui" exit 0 10-execute sh file and see following output: /Users/emre/Documents/MrProtect/tests/Deployment/test_gui.app/Contents/MacOS/Python: replacing existing signature /Users/emre/Documents/MrProtect/tests/Deployment/test_gui.app/Contents/MacOS/test_gui: replacing existing signature 11-execute app and try to close app via activity monitor and observe that the app is closed although app started the launch agent. 12-you can re-execute app under /Applications/test_gui.app/Contents/MacOS folder with "./test_gui" or even with sudo "sudo ./test_gui" commands you would see following error message for both launchctl load and bootstrap returns: "Load failed: 5: Input/output error". So if you close the app, it will not be re-opened Moreover console tool launchd.log output shows also (1: Operation not permitted) error for launchctl load and bootstrap commands My questions: 1-Is there any other method different than launch agent for keep alive? I researched it in internet but I could not find any other method unfortunately. Moreover launch agent is not user friendly anyway, with the reason that sandboxed apps cannot copy paste any files under LaunchAgents folder automatically. I am planning to provide my plist file to users that they can copy paste the file themself into launch agent folder out of sandbox. 2-How can i get rid of "Load failed: 5: Input/output error", thereby I can proceed at least with lanuchctl? What I have tried additionally: 1-I have also tried to use these linux commands, before executing my sandboxed standalone app file: sudo -S chown 600 /Library/LaunchAgents/com.test_gui.macos.plist sudo -S chown root:wheel /Library/LaunchAgents/com.test_gui.macos.plist 2-I have already given security fulldisk access to my test_gui app, but it also did not work My Requirements: Nuitka: 1.9rc5 Commercial: None Python: 3.9.12 (v3.9.12:b28265d7e6, Mar 23 2022, 18:22:40) Flavor: CPython Official Executable: /Library/Frameworks/Python.framework/Versions/3.9/bin/python3.9 OS: Darwin Arch: x86_64 Version C compiler: /usr/bin/clang (clang). macOS Sonoma: 14.2.1
Posted
by EmreGun.
Last updated
.
Post not yet marked as solved
2 Replies
341 Views
I have made an app that requires a daemon to run. For this I use the ServiceManagement framework and the SMAppService.register to register the daemon. The macOS 14.4 update broke the installation process and the daemon cannot be installed anymore and instead returns an error when trying to install the helper. The installation works on MacOS 14.3.1 or lower. I have narrowed the error to the main app being sandboxed. Both the daemon and the main app are sandboxed (as MacOS 14.2 introduced the restriction that a sandboxed app can only run/install a sandboxed daemon, https://developer.apple.com/documentation/macos-release-notes/macos-14_2-release-notes#ServiceManagement). I have been able to confirm that removing the sandbox on the main application results in the register function working again on MacOS 14.4. However, the release notes of 14.4 do not mention anything regarding the ServiceManagement API or something related. So my question is, what has changed in MacOS 14.4 so that the register function for a daemon causes an error when the main app is sandboxed? And moreover, how can I prevent this error without removing the sandbox -- Information regarding the error: The .register function returns the following error: Error Domain=SMAppServiceErrorDomain Code=22 "Invalid argument" UserInfo={NSLocalizedFailureReason=Invalid argument I have also created a log file according to the procedure at the link below and attached it to this post: https://forums.developer.apple.com/forums/thread/707482#716553022 It appears from the log file and from observing the logs in the Console app, that the error "plist changed between client and smd" causes the issue but I don't understand what causes this error out2 2.log -- (I already use the com.apple.security.temporary-exception.sbpl entitlement in the daemon such that it can write to a specific file that the pmset command write to when invoked. This to indicate that I would prefer to keep the main app sandboxed as well. As I could also just remove the sandbox but I don't want to do that)
Posted
by sake_s.
Last updated
.
Post not yet marked as solved
2 Replies
234 Views
I am developing an app, in this case for macOS. My app has two parts: A GUI A Server From the GUI i can start and stop the serve. My problem is that i need the server starts when the mac boots. Using the LaunchAgents i got to launch it when the user logins on, but i need to initiate it before. I saw that i need to saving my .plis inside of /Library/LaunchDaemons. I did it but when i restart the computer the server didn t initiate. I checked that my service gave me the status 1 so, it didn t launch correctly. Maybe the failure is inside the plist... but i dont understand why it works in LaunchAgent and not inside LaunchDaemons My plist is: &lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt; &lt;plist version="1.0"&gt; &lt;dict&gt; &lt;key&gt;Label&lt;/key&gt; &lt;string&gt;com.turnoffpc.turnoffpcplist&lt;/string&gt; &lt;key&gt;ProgramArguments&lt;/key&gt; &lt;array&gt; &lt;string&gt;/Applications/Turn Off PC.app/Contents/Resources/Turn Off PC/Server/dist/turn_off_pc_server.app/Contents/MacOS/turn_off_pc_server&lt;/string&gt; &lt;/array&gt; &lt;key&gt;RunAtLoad&lt;/key&gt; &lt;true/&gt; &lt;/dict&gt; &lt;/plist&gt; For loading the service im using the following sh: #!/bin/bash # Copiar el archivo plist a /Library/LaunchDaemons/ sudo cp com.turnoffpc.turnoffpcplist.plist /Library/LaunchDaemons/ # Establecer los permisos adecuados sudo chown root:wheel /Library/LaunchDaemons/com.turnoffpc.turnoffpcplist.plist sudo chmod 644 /Library/LaunchDaemons/com.turnoffpc.turnoffpcplist.plist # Descargar y luego cargar el servicio utilizando launchctl sudo launchctl unload /Library/LaunchDaemons/com.turnoffpc.turnoffpcplist.plist sudo launchctl load /Library/LaunchDaemons/com.turnoffpc.turnoffpcplist.plist I checked that the service is in the correct location The path to my app is: inside /Applications Turn Off PC.app Resources Turn Off PC - Server - dist - turn_off_pc_server.app - Contents - MacOS - turn_off_pc_server Someone sees the error or the thing that i am doing wrong? Thanks in advance
Posted
by Keickd.
Last updated
.
Post not yet marked as solved
2 Replies
304 Views
Hi, we are working on an application which will perform scheduled backup tasks in macOS 14. The app has been granted full disk permission. Recently we updated the code signing for the executable (/Applications/MyApp.app/Contents/MacOS/MyApp below) for passing the new notarization. After that, we found launchctl unable to load the plist for the schedule job &lt;!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt; &lt;plist version="1.0"&gt; &lt;key&gt;Label&lt;/key&gt; &lt;string&gt;com.MyApp.scheduler&lt;/string&gt; &lt;key&gt;ProgramArguments&lt;/key&gt; &lt;array&gt; &lt;string&gt;/Applications/MyApp.app/Contents/MacOS/MyApp&lt;/string&gt; &lt;string&gt;/Applications/MyApp.app&lt;/string&gt; &lt;/array&gt; &lt;key&gt;RunAtLoad&lt;/key&gt; &lt;true/&gt; &lt;key&gt;AbandonProcessGroup&lt;/key&gt; &lt;true/&gt; &lt;key&gt;WorkingDirectory&lt;/key&gt; &lt;string&gt;/Applications/MyApp.app/bin&lt;/string&gt; &lt;/dict&gt; &lt;/plist&gt; Related error message found in /var/log/com.apple.xpc.launchd/launchd.log* 2023-12-13 13:59:34.639672 (system/com.MyApp.scheduler [13434]) &lt;Notice&gt;: internal event: SOURCE_ATTACH, code = 0 2023-12-13 13:59:34.644530 (system/com.MyApp.scheduler [13434]) &lt;Error&gt;: Service could not initialize: posix_spawn(/Applications/MyApp.app/Contents/MacOS/MyApp), error 0x1 - Operation not permitted 2023-12-13 13:59:34.644545 (system/com.MyApp.scheduler [13434]) &lt;Error&gt;: initialization failure: 23C64: xpcproxy + 38300 [1097][925DE4E7-0589-3B33-BB64-7BC2F8629897]: 0x1 2023-12-13 13:59:34.644548 (system/com.MyApp.scheduler [13434]) &lt;Notice&gt;: internal event: INIT, code = 1 2023-12-13 13:59:34.644915 (system/com.MyApp.scheduler [13434]) &lt;Notice&gt;: xpcproxy exited due to exit(78) We have tried to update the entitlements for library and main executable files while still not success on make it works again. We have no idea what else could do for troubleshooting this. &lt;!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt; &lt;plist version="1.0"&gt; &lt;dict&gt; &lt;key&gt;com.apple.security.cs.allow-jit&lt;/key&gt; &lt;true/&gt; &lt;key&gt;com.apple.security.cs.allow-unsigned-executable-memory&lt;/key&gt; &lt;true/&gt; &lt;key&gt;com.apple.security.cs.disable-library-validation&lt;/key&gt; &lt;true/&gt; &lt;key&gt;com.apple.security.cs.allow-dyld-environment-variables&lt;/key&gt; &lt;true/&gt; &lt;key&gt;com.apple.security.cs.debugger&lt;/key&gt; &lt;true/&gt; &lt;key&gt;com.apple.application-identifier&lt;/key&gt; &lt;string&gt;...&lt;/string&gt; &lt;key&gt;com.apple.developer.team-identifier&lt;/key&gt; &lt;string&gt;...&lt;/string&gt; &lt;/dict&gt; &lt;/plist&gt; Appreciate for any suggestions. Thank you.
Posted
by annng.
Last updated
.
Post not yet marked as solved
1 Replies
298 Views
When registering the LaunchDaemons of the application using SMAppService:registerAndReturnError, I am seeing the below error. The operation couldn’t be completed. Codesigning failure loading plist: <plist name> code: -67054 Above issue is seen only on Ventura 13.0.1 and Ventura 13.1 versions. It is working fine on Ventura 13.5, Ventura 13.6 and Sonoma 14.2 as well. When I checked the system logs using sudo log stream --debug --info --predicate "process in { '<my process>', 'smd', 'backgroundtaskmanagementd'} and sender in {'ServiceManagement', 'BackgroundTaskManagement', 'smd', 'backgroundtaskmanagementd'}" I see below error 2024-02-27 16:02:22.382487+0530 0x4c006 Error 0x0 321 0 smd: [com.apple.libxpc.SMAppServiceShared:all] Static code signature check failed: -67054 2024-02-27 16:02:22.382500+0530 0x4c006 Error 0x0 321 0 smd: [com.apple.libxpc.SMAppServiceShared:all] Unable to validate code signature on bundle for <private>. Code: -67054 2024-02-27 16:02:22.384288+0530 0x4c006 Error 0x0 321 0 smd: [com.apple.xpc.smd:SMAppServiceFactory] Unable to load plist: <private> subpath: <private> status: -67054 There is no difference in the code between. There is no modification to the application bundle after codesigning in both cases (working and not working). Can someone let me know why is there a difference in the behavior in the earlier Ventura versions? Any steps to debug and resolve this issue would be highly appreciated. Thanks
Posted Last updated
.
Post not yet marked as solved
23 Replies
1.1k Views
Hi there :) I try to put an Xcode project in place within a LaunchAgent. The ultimate goal is to have an "application" with two component: macOS application with just an basic UI all the logic happens in a LaunchAgent that runs on background and is launch at startup. The macOS app uses XPC to send messages to the agent that will run either the app is opened or not. I struggled at first having this error (for the agent): An XPC Service cannot be run directly. Then I found using MachServices key in the .plist of the agent fixes the issue, plus: let listener = NSXPCListener.init(machServiceName: "com.tonygo.NetworkMonitorAgent") Then I wonder: Do we have somewhere a documentation about how to setup a LaunchAgent in Xcode I create the plist of the agent on side and run it manually, I could do this in a more automatic way How could I package a macOS applciation that will contains the agent, install it and load the agent? Note: This is mainly for learning and understanding what we could do at each level (XPCService, LaunchAgents, LaunchDaemon, etc.).
Posted
by tonygo.
Last updated
.
Post not yet marked as solved
1 Replies
256 Views
Hi, i have a daemon service written in Objective-C and C++. i need to detect user change events and reboot my service. I'm using SCDynamicStoreKeyCreateConsoleUser and get notifications for user switch events but not for fast user switch events. is there a way to reliably subscribe to all kinds of user switch events including VNC connection?
Posted
by alzix.
Last updated
.
Post marked as solved
1 Replies
341 Views
Since the macOS 14.2 update, services installed with SMAppService are required to be sandboxed when the main app is sandboxed as well (113037504). I had developed a daemon to communicate with the pmset interface, as that requires root privileges to make changes. Since the macOS 14.2 this daemon executable has to be sandboxed as well if I want my main app to be sandboxed. When sandboxing the daemon, it requires a temporary exception entitlement as the pmset command writes to one of the following two preference located in /Library/Preferences/: com.apple.PowerManagement.plist com.apple.PowerManagement.{UUID}.plist The specific command I use writes to the latter, which includes some specific UUID, that is specific to that device. When I use the: com.apple.security.temporary-exception.shared-preference.read-write entitlement with com.apple.PowerManagement.0000 where 0000 is the exact UUID string as on my Mac, the daemon is able successfully use the pmset command. This results however in that on other user devices it would not work as the UUID in the preference name would be different. When I try setting it to a wildcard variation such as com.apple.PowerManagement.*, the command doesn't run anymore as this format for the exception entitlement seems to be unsupported. My question is now, is there any way to get an exception entitlement which accounts for the unique identifier or is that impossible and must I disable the sandbox altogether? (as I have to use a daemon, I am not developing for the Mac App Store and a sandbox isn't strictly necessary so it wouldn't break my app. Its more I would prefer to use sandboxing if possible) Thanks in advance! For reference, this is the error I get when the entitlement is set incorrectly or not set: rejecting write of key(s) AC Power in { com.apple.PowerManagement.0000, kCFPreferencesAnyUser, kCFPreferencesCurrentHost, /Library/Preferences/com.apple.PowerManagement.0000.plist, managed: 0 } from process 15694 (pmset) because setting preferences outside an application's container requires user-preference-write or file-write-data sandbox access
Posted
by sake_s.
Last updated
.
Post not yet marked as solved
21 Replies
4.2k Views
I've got an app that is sandboxed, and it requires a privileged helper. I've worked through the EBAS sample app with various updates to conform with current systems. After a lot of work, I've got to a point where I'm stumped. The Python script SMJobBlessUtil.py returns this error, and I don't know what to do to correct it: &lt;path to helper tool&gt;: tool __TEXT / __info_plist section dump malformed (2) I've gone over the various settings numerous times. It doesn't fail for the EBAS sample, but does for my app. Looking at the binary, the __info_plist sections look identical apart from identifiers. This is what mine looks like (identifiers deleted): &lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt; &lt;plist version="1.0"&gt; &lt;dict&gt; &lt;key&gt;CFBundleIdentifier&lt;/key&gt; &lt;string&gt;***&lt;/string&gt; &lt;key&gt;CFBundleInfoDictionaryVersion&lt;/key&gt; &lt;string&gt;6.0&lt;/string&gt; &lt;key&gt;CFBundleName&lt;/key&gt; &lt;string&gt;***&lt;/string&gt; &lt;key&gt;CFBundleVersion&lt;/key&gt; &lt;string&gt;1.0&lt;/string&gt; &lt;key&gt;SMAuthorizedClients&lt;/key&gt; &lt;array&gt; &lt;string&gt;anchor apple generic and identifier "***" and (certificate leaf[field.1.2.840.113635.100.6.1.9] /* exists */ or certificate 1[field.1.2.840.113635.100.6.2.6] /* exists */ and certificate leaf[field.1.2.840.113635.100.6.1.13] /* exists */ and certificate leaf[subject.OU] = "***")&lt;/string&gt; &lt;/array&gt; &lt;/dict&gt; &lt;/plist&gt; I must be missing something, but I've run out of ideas on where to find it. Anybody got a pointer?
Posted
by Mussau.
Last updated
.
Post not yet marked as solved
3 Replies
366 Views
Hello, we are currently working on a plan to migrate our app suite from Developer ID binaries inside a simple pkg installer to macOS app store distribution. The reason we are using an installer is that there are multiple binaries inside that communicate via XPC and we need to install the respective launchd plist in /Library/LaunchDaemons and /Library/LaunchAgents: 1 root daemon 1 agent that has minimal UI and lives in the system menu bar 1 embedded command line utility in user agent 1 embedded FileProvider extension in user agent 1 embedded Action Extension in user agent 1 agent that only does OAuth stuff Looking through Updating helper executables from earlier versions of macOS I can install the root daemon with SMAppService.daemon(plistName:) and the OAuth helper with SMAppService.agent(plistName:). For the main application I only found SMAppService.mainApp which does not accept a property list configuration. Therefore, I have no place to put my MachServices array and so the File Provider extension, the Action Extension, and the embedded command line utility have no way to talk to the user agent. Currently, XPC is used in between these processes: user agent -> root daemon command line utility -> user agent action extension -> user agent file provider extension -> user agent user agent -> file provider extension: that already works through NSFileProviderServicing I know app-to-app communication only works through launchd for security reasons, but these applications are all part of the same app group (except the root daemon obviously). My question is what is the proper way of starting the user agent so XPC from other binaries just work ™️? Any input is much appreciated!
Posted
by WoamaHons.
Last updated
.
Post not yet marked as solved
0 Replies
312 Views
Because I can't find a way to share StoreKit purchases between two apps (macOS), I was forced to make my LSUIElement application a single app. This is turning out to work reasonably well, except for one issue that I hadn't noticed before (maybe it's new in 14.2?). The normal flow is this: User double-clicks app icon App calls SMAppService.agent(plistName: "com.myagent.plist").register(). The referenced plist points to the same application binary (see attached project) that the user launched in step 1. System launches a second instance of the application binary What I want the call to do instead is see that the app is already running, and just adopt it (that is, if it is killed or crashes, relaunch it). I see two inelegant workarounds: Wait until the user is done configuring the app after first launch, register the app and then quit. Thing is, I can't be sure when they're done, e.g. if they don't close the window. Allow both instances of the app to run, but quit if they close the window and it wasn't launched by launchd, or if there are other instances running. This feels fragile (e.g. if the behavior of register() is ever improved as I'd like). The best solution, of course, would be to share StoreKit context between apps, so I could separate this into the UI app and background agent. (To Apple: I've filed FB13574819 with my project attached.)
Posted
by JetForMe.
Last updated
.
Post not yet marked as solved
4 Replies
402 Views
I have a application that is only the UI for a daemon service. The daemon itself is runnning ok, so far. Now when the user moves the App to trash bin, will the daemon also be uninstalled? How does most MacOS software does that behind the scenes? Like, MS Teams, it runs a daeamon but when the user removes the app the daeamon should be also removed. I am using Packages for installing, so I can for example update, but differently from Windows we normally don`t have an uninstall program. I would appreciate any explanation on that, as for my research I was able to find only how to create daemons.
Posted Last updated
.
Post not yet marked as solved
2 Replies
358 Views
I have an application which uses Service Management framework to register a LaunchAgent. The LaunchAgent registers a mach service with a specific name and it listens for connections made by my application. Also the agent is registered relative to the app bundle using BundleProgram parameter in the agent plist. My problem is that after the initial registration the service always points to the path where my app bundle was located in the time of registration. Here is an example: I download my app from the AppStore and it places it in the /Applications directory. I open it and my service is registered. Then when I want to develop/debug/etc.. from Xcode I build the same app with the same service and I re-register the service from my Debug build and the service still points to the service in the /Applications directory. I tried the use case when I have two builds of my app with a different CFBundleVersion. The LaunchAgent version was the same as the version which made the initial registration, i.e. no matter which app version I use and that I re-register my service, still the initial registered version of the service is used. Based on the documentation in SMAppService.h: If an app updates either the plist or the executable for a LaunchAgent or LaunchDaemon, the SMAppService must be re-registered or it may not launch. It is recommended to also call unregister before re-registering if the executable has been changed. I think that re-registering the application should work in the aforementioned use cases. The only workaround I have found so far is: delete the application which made the initial registration of the service log out log in and open the desired app version and register the service with that version. Does anyone have the same problem and is there a more correct way to handle this use case? Is there a problem in the way I'm using the ServiceManagement framework? Should I write a feedback report to Apple about this problem?
Posted Last updated
.