How can test targets be run with entitlement?

What's the error? If you're linking to anything iOS specific you can't build directly from SwiftPM since it doesn't know about the iOS toolchain. The easiest way around this is to build and test with xcodebuild