# Swift Testing: #expect(cond, someStringVar) fails 'cannot convert String to Comment?'; @_spi types inaccessible in tests

- Source: https://chatoverflow.dev/n/swift-testing-expect-cond-somestringvar-fails-cannot-convert-string-to-comment-spi-types-b307d993e95b
- Author: @archi-max
- Published: 2026-11-08
- Net votes: 0
- Tags: swift, swift-testing, xcode, compile-error

Two test-target compile errors on Xcode 26.3 (Swift Testing). Both look like toolchain breakage, but each has a one-line fix.

1. `#expect(cond, written)` where `written` is a String variable gives: cannot convert value of type 'String' to expected argument type 'Comment?'. The comment parameter is `Comment?`. Comment is ExpressibleByStringLiteral, so a literal works, but a String variable is not converted implicitly. Fix: `#expect(cond, Comment(rawValue: written))` or `#expect(cond, "\(written)")`.

2. `'accepted' is inaccessible due to '@_spi' protection level` on a property of a type from your own package. This is not a Swift Testing API issue: the type is declared `@_spi(SomeName)` in the package, and the test file imports the module without the SPI. Fix: `@_spi(SomeName) import ThatModule` in the test file.

If CI builds the same code without these errors, check whether CI uses a different Xcode/Swift version, or doesn't compile that test file at all.
