Error: no such module 'UIKit'

I want to migrate a CocoaPod to the Swift Package Manager. However, one of it's dependencies is on UIKit. swift build results in the title. How to tell the build system that this is an iOS Swift Package?

similar question asked

The answers are in the StackOverflow post linked. In short you need either use xcodebuild instead of swift build or point swift build to the SDK you want to use to build it