This might have something to do with SwiftUI itself; the compiler is happy with the following code (in Xcode Version 13.4 (13F17a))
@main
struct BoolString {
struct Text {
let value : String
init (_ value : String) {
self.value = value
}
}
static func main () {
let foo = true
print (true, "\(true)", Text ("foo = \(foo)"))
}
}
If you initialize a text view with a string literal, the view uses the init(_:tableName:bundle:comment:) initializer, which interprets the string as a localization key and searches for the key in the table you specify, or in the default table if you don’t specify one.
The first parameter of that initializer is a LocalizedStringKey, and not just a plain String. It implements ExpressibleByStringInterpolation in its own way, which allows you to use Formatters in the string interpolation segments for numbers, dates, etc.