How to prevent the Photos app from launching cloudphotosd, photoanalysisd, etc?

A number of the background services used by the Photos app perform functions I'm not interested in benefitting from (and in some cases, actively do not want). Primarily these are photoanalysisd and cloudphotosd. I'm reasonably certain that the former is not strictly necessary for the Photos app to operate (if needed for some features); I'm slightly less certain about the latter but that isn't precisely the thrust of the question. (photolibraryd I'm aware the app needs in order to run properly at all, and so I'm not touching it).

Where I seem to be stuck is that their launching does not appear to respect launchctl disable. Indeed, launchctl print gui/$UID includes both daemons within the disabled services section, with the flag set to true, while neither are running, and the Photos app will still trigger these to be launched as soon as it is started. It isn't enabling them in launchd, as the flags remain unchanged when I check after testing by launching the Photos app.

Considering the possibility I was disabling them in the wrong launchd domain, I went on to try disabling them in the system domain, to no avail - launching Photos still starts these two services as soon as it starts.

I also attempted to use the legacy launchctl unload -w pattern on the corresponding .plist file in /System/Library/LaunchAgents/, but was informed by launchctl in that case that the service could not be found.

In case some volatile state needed to be flushed or reloading done, I shut down and rebooted the system subsequent to ensuring that those services were flagged as disabled. They still returned as soon as the Photos app was launched.

launchctl blame gui/$UID/cloudphotosd simply stated that the service was launched for xpc (mach), which doesn't really tell me much (the cross-process communication here is probably just the photos app launching the service).

I'm wondering how to really disable these particular background processes, so that they cannot be launched by the Photos app, without out and out deleting them from the system or making other "destructive" changes. Or in other words, while I could probably simply find their actual executables and move them somewhere for archival, not being all that familiar with the functioning of launchd I'm curious as to whether there is a way working within its system to really forbid certain services from being launched. I thought that was launchctl disable... but it seems not, as that does not appear to have any effect in this instance.

EDIT: Should clarify, this is on macOS 10.14/Mojave.


Solution 1:

Try running chmod -x on the binaries. This will prevent them from launching at all until you make them executable again.

I don't know how SIP will affect this, since you're modifying built-in programs. You may have to disable it.