Xcode on command line

I am trying to run Xcode on an AWS Mac OS instance (e.g. "open -a Xcode <myapp>.xcodeproj"). It gives me an error:
"The application /Applications/Xcode.app cannot be opened for an unexpected reason, error=Error Domain=NSOSStatusErrorDomain Code=-10826 "kLSNoLaunchPermissionErr: User doesn't have permission to launch the app (managed networks)" UserInfo={_LSFunction=_LSLaunchWithRunningboard, _LSLine=2508, NSUnderlyingError=0x7ffe8560d1f0 {Error Domain=RBSRequestErrorDomain Code=5 "Launch failed." UserInfo={NSLocalizedFailureReason=Launch failed., NSUnderlyingError=0x7ffe8560bd60 {Error Domain=OSLaunchdErrorDomain Code=125 "Domain does not support specified action" UserInfo={NSLocalizedFailureReason=Domain does not support specified action}}}}}"

Are running in an interactive (GUI) mode or just a terminal? I suspect it might the latter.

If you're not sure you can run the launchctl managername command to determine it. If it prints something else than Aqua it's most probably a non-interactive session and running graphical apps won't work.

See also the accepted answer on this SO question for a more precise way of detecting the type of your current session.

I'm not convinced. At the start of the year, I could SSH in to my Mac and launch Xcode from the SSHed terminal (lanchctl managername of "Background"), but some updates since have prevented this, resulting in this same error.

I've also found doing this from the terminal on the Mac (launchctl managername of "Aqua") only works when Xcode isn't already running, otherwise it says the same thing.

Xcode on command line
 
 
Q