Note that building the DocC documentation requires building the package first. Presumably, swift package generate-documentation functions similarly to swift build in that it only builds for the host platform. (In fact, the former probably calls through to the latter.) Therefore, SPM is trying to build your package on macOS, where UIKit doesn't exist.
In other words, swift build does not build for iOS, (except if you use the Xswiftc flag); therefore, swift package generate-documentation does not work for packages that must be built on iOS.
You'll probably have to use xcodebuild instead for this.
See this thread about the fact that SPM does not support building packages for iOS.