LaunchControl
public class LaunchControl
Control agents and daemons.
-
The shared instance
Declaration
Swift
public static let shared: LaunchControl -
Read a LaunchAgent from the user’s LaunchAgents directory
Throws
errors on decoding the property listDeclaration
Swift
public func read(agent called: String) throws -> LaunchAgentParameters
calledfile name of the job
Return Value
a LaunchAgent instance
-
Read a LaunchAgent from disk
Throws
errors on decoding the property listDeclaration
Swift
public func read(from url: URL) throws -> LaunchAgentParameters
urlurl of the property list
Return Value
a LaunchAgent instance
-
Writes a LaunchAgent to disk as a property list into the user’s LaunchAgents directory
The agent’s label will be used as the filename with a
.plistextension.Throws
errors on encoding the property listDeclaration
Swift
public func write(_ agent: LaunchAgent) throwsParameters
agentthe agent to encode
-
Writes a LaunchAgent to disk as a property list into the user’s LaunchAgents directory
Throws
errors on encoding the property listDeclaration
Swift
public func write(_ agent: LaunchAgent, called: String) throwsParameters
agentthe agent to encode
calledthe file name of the job
-
Writes a LaunchAgent to disk as a property list to the specified URL
.plistwill be appended to the URL if neededThrows
errors on encoding the property listDeclaration
Swift
public func write(_ agent: LaunchAgent, to url: URL) throwsParameters
agentthe agent to encode
calledthe url at which to write
-
Sets the provided LaunchAgent’s URL based on its
labelThrows
errors when reading directory contentsDeclaration
Swift
public func setURL(for agent: LaunchAgent) throwsParameters
agentthe LaunchAgent
-
Run
launchctl starton the agentCheck the status of the job with
.status(_: LaunchAgent)Declaration
Swift
public func start(_ agent: LaunchAgent) -
Run
launchctl stopon the agentCheck the status of the job with
.status(_: LaunchAgent)Declaration
Swift
public func stop(_ agent: LaunchAgent) -
Run
launchctl loadon the agentCheck the status of the job with
.status(_: LaunchAgent)Declaration
Swift
public func load(_ agent: LaunchAgent) throws -
Run
launchctl unloadon the agentCheck the status of the job with
.status(_: LaunchAgent)Declaration
Swift
public func unload(_ agent: LaunchAgent) throws -
Retreives the status of the LaunchAgent from
launchctlDeclaration
Swift
public func status(_ agent: LaunchAgent) -> AgentStatusReturn Value
the agent’s status
View on GitHub
LaunchControl Class Reference