Little SwiftUI trick I found somewhere on the internet that everyone should know:

You can put SF Symbols perfectly inline with Text by… creating a Text with the symbol Image (?) and then adding the Texts together (!).

The subhead here is:

(
Text(Image(systemName: "cloud”)) .accessibilityLabel(“Streamable, ”) +
Text(" ") +
Text(dateStr)
)

A handy utility function to generate these: https://gist.github.com/marcoarment/fdd9c19995e8f9d16bc2d10cd8cefe39

SwiftUI Text with inline SF Symbols

SwiftUI Text with inline SF Symbols. GitHub Gist: instantly share code, notes, and snippets.

Gist

@marcoarment

I am hesitant to do this ever since this kind of code was crashing my widgets...

I was getting this error: CodableTextAttachment.Error.invalidAttachment - The operation couldn’t be completed.

Blog post if anyone is interested in more details https://nemecek.be/blog/186/the-weirdest-bugcrash-in-widgets

The weirdest bug/crash in widgets?

Mysterious crash and ChatGPT to the rescue.