trilemma-dev / SecureXPC

A simple and secure XPC framework for Swift
MIT License
77 stars 15 forks source link

Dynamically creates a launch agent to facilitate testing #117

Closed jakaplan closed 2 years ago

jakaplan commented 2 years ago

A launch agent running as a completely separate process is now created, registered (load) with launchd, and can be communicated with. This allows for testing shared memory functionality in a separate process.

Cleanup logic also exists to unload the agent and delete all of the created files. However, the paths and service name are all randomly generated, so nothing bad ought to happen if cleanup fails (for example because a test fails).

Building SecureXPC from scratch takes a long time, so the code has been written in such a way that people using this framework can provide a path to the pre-built module - this will speed things up about 25x.

For reference, these were helpful resources in figuring out how to use swiftc:

jakaplan commented 2 years ago

@amomchilov For your future reference, if you want to write tests which access a launch agent that runs in a completely separate process that will now be possible.