To expand slightly on @Juguang's answer:
extension AttributedString {
func toString() -> String {
return self.characters.map { String($0) }.joined(separator: "")
}
}
Usage:
print("Working value = \(workingAttribStrng.toString())")
Current Swift (as of December 2024, Xcode 16.1, Swift 5.10) won't accept the earlier answers, but this seems to work fine, and this thread is what comes up first when searching for "Swift AttributedString to plaintext".