Preferred way to detect macOS Server?

Working on a Swift / ObjC tool that needs to interact with the files and directories created and used by Server.app, as well as some other system components.


I've looked around here in the developer forums, have run various DDG searches, rummaged the developer documentation, and don't see a documented way of detecting the presence of macOS Server.app in the local system configuration.


The approaches available involve NSTask or analogous of the serverinfo command (and catch the error when that's not present, or read and process the command output or XML data when it is), or the use of Spotlight to rummage for the presence of the Server.app bundle, or to simply go look for the /Applications/Server.app bundle.


All seemingly somewhat hackish as, for instance, the Server.app bundle might "just" be being used as a client to access a remote server and not running locally.


Or just assume that Server.app is present and configured, and which I'd really rather not do if there's a better way.


Is there a preferred or better way to detect whether Server.app is present and configured?


Also not subject to MAS rules, given what the tool will be doing, too.

Replies

The underlying problem here is one of definition: how do you define macOS Server? Is it the presence of the installed server components? Or do they have to be running? And, if so, which ones? This issue is complicated by the fact that the decision as to which services are available on macOS Server (vs vanilla macOS) has changed over time. For example:

  • Back in the day, macOS had a Personal Web Server feature but that has disappeared in recent releases

  • macOS 10.13 beta [client] supports the Caching Server

  • Xcode 9 beta no longer requires macOS Server

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

I'm aware that the components of server have changed, as have the directory paths and other details, that not everything gets started in every configuration, or even configured, etc.


I'm specifically after the Apache-related paths for this particular case, and those change between macOS and macOS with server installed, and those have also occasionally changed across major versions of the server software. (e.g. from 10.6 to 10.7, etc.)


It seems that issuing the serverinfo command is probably the "best" way of what's available; that there's no framework to ask for this system configuration data. I'm not all that keen on parsing XML as the solution, but it's certainly feasible.


It's probably far too late for High Sierra, but it'd be nice if there were a way to retrieve this configuration data and preferably that macOS and Server.app both shared. That way, apps can adapt to installation on client macOS, or on the server configuration. Or at least detect client or server as warranted, and exit with appropriate errors. (I'll log a radar.)


I'll be pulling down the developer beta for a look at what's in High Sierra and Server.app in this same area, but that's not today.


Ah, well. Thanks.

It's probably far too late for High Sierra, but it'd be nice if there were a way to retrieve this configuration data and preferably that macOS and Server.app both shared.

It’s never too late to file an enhancement request for the next OS release (-:

Please post your bug number, just for the record.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"