How can I read the battery level of a MacBook in Swift?

Yes, it can be done fully in Swift. You mention that you have found a sub-optimal solution for you in using the "ioreg" command line tool. You can find the full source code (in C) for the ioreg tool here - for inspiration:

https://github.com/opensource-apple/IOKitTools/blob/master/ioreg.tproj/ioreg.c

That tool gets the battery level for you by reading the properties of the I/O devices - the battery level being one such property. It reads them using a function that in Swift is available as IORegistryEntryCreateCFProperties() in the IOKit framework.