Skip to main content

How to fix “Cannot convert value of type 'String' to expected argument type 'Text'”

About 2 minSwiftSwiftUIArticle(s)bloghackingwithswift.comcrashcourseswiftswiftuixcodeappstore

How to fix “Cannot convert value of type 'String' to expected argument type 'Text'” 관련

SwiftUI by Example

Back to Home

How to fix “Cannot convert value of type 'String' to expected argument type 'Text'” | SwiftUI by Example

How to fix “Cannot convert value of type 'String' to expected argument type 'Text'”

Updated for Xcode 15

This is a really common error, and happens because you tried to use a string where SwiftUI expects to have a Text view. As a simple example, it means creating an alert like this:

Alert(title: "Meh")

There are many places where SwiftUI wants to have a Text view rather than a plain string, so just wrap your strings in text like this:

Alert(title: Text("Meh"))
Similar solutions…
How to fix “Cannot convert value of type 'String' to expected argument type 'Binding'” | SwiftUI by Example

How to fix “Cannot convert value of type 'String' to expected argument type 'Binding'”
How to fix “Cannot convert value of type '() -> ()' to expected argument type '() -> _'” | SwiftUI by Example

How to fix “Cannot convert value of type '() -> ()' to expected argument type '() -> _'”
How to fix “Cannot assign to property: 'self' is immutable” | SwiftUI by Example

How to fix “Cannot assign to property: 'self' is immutable”
How to fix “Missing argument for parameter 'content' in call” | SwiftUI by Example

How to fix “Missing argument for parameter 'content' in call”
How to format text inside text views | SwiftUI by Example

How to format text inside text views

이찬희 (MarkiiimarK)
Never Stop Learning.