SwiftUI not support non-ASCII character as identifier in binding data.

The mini demo as follow.

Code Block swiftstruct home: View {    @State var 😄 = false       var body: some View {        // '$' is not an identifier; use backticks to escape it        // Cannot find '$' in scope        FooView(bar: $😄)    }}struct FooView: View {  @Binding var bar: Bool  // ...}


That would be normal when use ASCII character to replace emoji.
Answered by OOPer in 638961022
An interesting experiment.

Currently property-wrapper-projection is defined as follows in the Swift book.

property-wrapper-projection → $ identifier-characters

The emoji you have shown (U+1F604) is included in identifier-character, so $😄 should be a valid identifier.

Seems the current Swift parser is not implemented as it should be. The difference is not so slight that can be omitted.
You should better send a bug report using Feedback Assistant to Apple or using bugs.swift.org to swift.org.

Accepted Answer
An interesting experiment.

Currently property-wrapper-projection is defined as follows in the Swift book.

property-wrapper-projection → $ identifier-characters

The emoji you have shown (U+1F604) is included in identifier-character, so $😄 should be a valid identifier.

Seems the current Swift parser is not implemented as it should be. The difference is not so slight that can be omitted.
You should better send a bug report using Feedback Assistant to Apple or using bugs.swift.org to swift.org.

I have update the new Xcode12.1 and use swift5.3, it still has the similar problem.
SwiftUI not support non-ASCII character as identifier in binding data.
 
 
Q