I have a question regarding the deprecation of the plus sign to concatenate strings containing SF symbols.
In iOS 18 I could use the following text in my app:
Text(“Tap the keyboard down button (“) + Text(Image(systemName: “keyboard.chevron.compact.down”)).foregroundStyle(Color(.systemBlue)) + Text(“) to close the keyboard.”)
In iOS 26 this gives the warning:
'+' was deprecated in iOS 26.0: Use string interpolation on
Textinstead:Text("Hello \(name)”)
So upgrading to the new change I tried:
Text("Tap the keyboard down button (\(Image(systemName: "keyboard.chevron.compact.down").foregroundStyle(Color(.systemBlue))) to close the keyboard”)
But this gives the warning:
'appendInterpolation' is deprecated: Localized string interpolation produces an unlocalized, debug description for this type of value. Use a type supported by LocalizedStringKey.StringInterpolation or initialize a LocalizedStringResource instead with an interpolated value that conforms to CustomLocalizedStringResourceConvertible.
It appears that I can no longer set the SF symbol color. Am I missing something, or is there another way to set the color of the SF symbol using iOS 26 within a text string?
It works without compiler warnings if the symbol is created as a separate Text element that is then used as the interpolated string:
let symbol = Text(Image(systemName: "keyboard.chevron.compact.down")).foregroundStyle(.blue)
Text("Tap the keyboard down button (\(symbol)) to close the keyboard")
You can actually do it all in one statement if you really want to:
Text("Tap the keyboard down button (\(Text(Image(systemName: "keyboard.chevron.compact.down")).foregroundStyle(.blue))) to close the keyboard")
If you want to localize the text, %@ can be used as the placeholder for the Text holding the symbol:
"TEXT_WITH_SYMBOL %@" = "Tap the keyboard down button (%@) to close the keyboard";
Text("TEXT_WITH_SYMBOL \(symbol)")

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With