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 -> LaunchAgent
Parameters
called
file 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 -> LaunchAgent
Parameters
url
url 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
.plist
extension.Throws
errors on encoding the property listDeclaration
Swift
public func write(_ agent: LaunchAgent) throws
Parameters
agent
the 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) throws
Parameters
agent
the agent to encode
called
the file name of the job
-
Writes a LaunchAgent to disk as a property list to the specified URL
.plist
will be appended to the URL if neededThrows
errors on encoding the property listDeclaration
Swift
public func write(_ agent: LaunchAgent, to url: URL) throws
Parameters
agent
the agent to encode
called
the url at which to write
-
Sets the provided LaunchAgent’s URL based on its
label
Throws
errors when reading directory contentsDeclaration
Swift
public func setURL(for agent: LaunchAgent) throws
Parameters
agent
the LaunchAgent
-
Run
launchctl start
on the agentCheck the status of the job with
.status(_: LaunchAgent)
Declaration
Swift
public func start(_ agent: LaunchAgent)
-
Run
launchctl stop
on the agentCheck the status of the job with
.status(_: LaunchAgent)
Declaration
Swift
public func stop(_ agent: LaunchAgent)
-
Run
launchctl load
on the agentCheck the status of the job with
.status(_: LaunchAgent)
Declaration
Swift
public func load(_ agent: LaunchAgent) throws
-
Run
launchctl unload
on 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
launchctl
Declaration
Swift
public func status(_ agent: LaunchAgent) -> AgentStatus
Return Value
the agent’s status