I followed the instructions described in How to build Swift Package as XCFramework
I also wrote an article about it: