How can test targets be run with entitlement?

While that will work to target an iOS device, for Keychain specifically you need a test host to get the proper entitlements which is not possible with the Swift Package Manager. You'll need to create an xcodeproj to handle that testing. I forgot that I actually asked about this very scenario way back Host Application for SPM Tests

3 Likes