How to conditionally polyfill String.init(unsafeUninitializedCapacity:_:) by macOS version?

As noted in your side question (Why won’t swift-hash build on the Swift Package Index?), this is likely because you haven't correctly excluded your executable target.