This has been asked previously and in short, there hasn't been a good way of doing this up to and including macOS 12 'Monterey'.
However, there have been some changes in this area with macOS 13.0 Ventura; there's an introduction to the new mechanism in the WWDC22 session 'What’s new in privacy'. The new SMAppService
APIs support automatic cleanup. Unfortunately you'll of course still have to find a workaround for any older macOS versions you support.
One way to ensure you don't consume unnecessary resources on a user's system, especially if uninstall isn't clean and the user isn't expecting your code to be lying around on their system anymore, is to avoid launching your daemon on every boot. Try to make it launch conditionally based on events, such as when your app first tries to connect via XPC/Mach, or using IOKit XPC events when the user first plugs in the device your daemon is driving.