Does anyone know how I can include an entitlements file in my package so that the tests run with that entitlement?
Background
I've migrated some code into a little package that wraps the iOS Keychain which seems to be working well. However the tests are crashing with an error. The internet (and the Apple forums) suggest that the fix to this error is to have an entitlements file (even empty) when running the app.
I think I could also add an Xcode project and have that set up but it would be nicer to do it all within the Package approach.
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
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
When running a unit test target requiring a qualification keychain access it doesn't work out of the container on Xcode. You get some clear mistake in the comfort about a missing qualification. Everything turns out great on the test system however.