'How to run swift commands from swift code?

I'm wondering if there is some sort of API to call swift cmdline commands in swift code.
I know that I can use Process to run commands like swift build etc. but this seems a bit unswifty for me, so I thought there might be a official API or framework for this.
Has somebody experiences with this or knows where I can find more info?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source