Automatically fix Non-Breaking Space Character in Source Files in Xcode

Originator:hannes.oud.dev
Number:rdar://35006066 Date Originated:16-Oct-2017 04:13 PM
Status:Open Resolved:
Product:Developer Tools Product Version:Version 9.1 beta (9B46)
Classification:UI/Usability Reproducible:Always
 
Summary:
Non-Breaking Space should automatically be replaced by an ordinary space character in Swift source code (except in Strings and comments).

When typing an opening bracket (OPTION+8) followed by a space on a german keyboard, somehow, Xcode source editor often inserts a non-breaking space character (as typed with OPTION+SPACE) instead of just space. This causes the compiler to report an invalid character. For unknown reasons this mostly occurs when typing the else block of guard statements. 

Steps to Reproduce:
Have a german keyboard
Open a Swift file
Quickly type a guard statement with ‚else‘ block starting with opening bracket + space



Expected Results:
No issue should arise, a space should be inserted after the bracket

Actual Results:
A non-breaking space is inserted after the bracket and compilation fails.
A fix-it shows: „Invalid character in source file“

Version:
Version 9.1 beta (9B46)

Notes:
This is happening throughout my team many times per day, so I think it is not only my clumsiness.
The resulting fix-it could be automatically be applied.
Or it could be handled similar to the „While editing: Automatically trim trailing whitespaces“ setting

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!