Text + Text is deprecated in SwiftUI
Table of Contents
If you raise your app's minimum version to iOS 26, you might see a new warning on code that has worked since iOS 13.
The warning says: '+' was deprecated in iOS 26.0: Use string interpolation on Text instead: Text("Hello \(name)")
In this article, we will learn why Apple made this change.
The replacement
+ is how many of us style part of a sentence. I used it myself in How to make parts of Text view Bold.
// Before
Text("Tap ") + Text("Save").bold() + Text(" to keep your changes.")
The replacement is to put the styled Text inside the string with interpolation.
// After
Text("Tap \(Text("Save").bold()) to keep your changes.")
Both look the same on screen. "Save" is still bold, and the result is still one Text, so it wraps like a normal paragraph.
If the inner Text makes the line too long, move it to a constant.
let save = Text("Save").bold()
Text("Tap \(save) to keep your changes.")
Putting a Text inside another Text with interpolation works since iOS 14, so you can switch even if your app supports older versions.
You can easily support sarunw.com by checking out this sponsor.
Screenshot Studio: Create App Store screenshots in seconds not minutes.
Why it was deprecated
+ is deprecated because it makes your text hard to translate correctly.
When you join pieces with +, the order of the sentence is fixed in your code. That order is right for English, but not for every language.
Let's see what that means in a real app.
Each piece becomes its own string
A Text with a string literal is a localized string. Xcode adds each one to your String Catalog as a separate string to translate.
With +, our sentence becomes three strings.
"Tap "
"Save"
" to keep your changes."
With interpolation, we get one string for the whole sentence and one for the word.
"Tap %@ to keep your changes."
"Save"
%@ is a placeholder. It marks where "Save" goes.
Word order is different in other languages
With +, a translator gets the pieces and translates them one by one, without seeing the sentence. Even if every piece is translated well, your code still decides the order.
"Tap Save to keep your changes." keeps the same word order in Thai, so + gets lucky there. Here is a phrase where it doesn't: a bold name followed by "'s photos".
// Before
Text(name).bold() + Text("'s photos")
// After
let owner = Text(name).bold()
Text("\(owner)'s photos")
In Thai, the owner comes last. "Anna's photos" is "รูปภาพของ Anna", which is "photos of Anna".
With +, the name isn't a string to translate, so the translator only gets "'s photos". It becomes "รูปภาพของ" ("photos of"), and + glues it after the name. We get "Annaรูปภาพของ", which isn't correct in Thai.
With interpolation, the translator gets "%@'s photos" and can move %@ to wherever it belongs: "รูปภาพของ %@".
You can easily support sarunw.com by checking out this sponsor.
Screenshot Studio: Create App Store screenshots in seconds not minutes.
Conclusion
- Apple's reason is localization.
+locks the order of a sentence in your code, and translators only get the pieces. - Replace it with interpolation:
Text("Tap \(save) to keep your changes."). It works back to iOS 14.
The same interpolation works with images too. If you want an icon inside a sentence, check out How to add inline images with text in SwiftUI.
Read more article about SwiftUI, iOS 26, Text, or see all available topic
Enjoy the read?
If you enjoy this article, you can subscribe to the weekly newsletter.
Every Friday, you'll get a quick recap of all articles and tips posted on this site. No strings attached. Unsubscribe anytime.
Feel free to follow me on Twitter and ask your questions related to this post. Thanks for reading and see you next time.
I also make short videos and visual guides on Patreon. Some things are easier to see than to read, like how an API looks and moves on a real screen. If you like to learn that way, come and watch. Sharing the article is also greatly appreciated.
Become a patron Tweet ShareHow to move a navigation title to the leading edge in SwiftUI
iOS 27.2 adds toolbarTitleAlignment(_:). Learn what .automatic, .leading, and .center do with inline titles, large titles, subtitles, toolbar buttons, and iPhone Duo.