Also, if you change the optimization level to "-Onone" in "Swift Compiler - Code Generation" -> "Build Settings" -> "Release", then the original code(without workaround) works fine.
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: