Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No-break space causing problems in Xcode

Tags:

xcode

unicode

Quite often when I code in Xcode, I type no-break space (Option + Space / Option + Shift + Space) especially before or after square brackets or curly braces. This causes Xcode to give warning:

invalid character in source file

Is there any way to prevent this behavior, as it is really annoying and rarely necessary? I tried to look for an answer in Xcode menus and Google but didn't find anything proper.

like image 546
Aleksi Sjöberg Avatar asked Feb 26 '15 18:02

Aleksi Sjöberg


2 Answers

I also had that problem (xCode 7.2) and found a workaround by assigning Option+Space and Option+Shift+Space to "Make Text Writing Direction Left ToRight" in Xcode

  • Preferences (menu)
  • Key Bindings(section)
  • Default(drop down)
  • Text(tab)
  • Writing Direction(section)
  • Make Text Writing Direction Left ToRight(command)
  • Double-click and use (+) on the right to add key bindings.

You could assign them to any other command that doesn't have a useful effect for you.

It will make it seem that the space bar is not responding when you accidentally hold the modifier keys but that's much less of a time waster than the compilation errors.

like image 162
Alain T. Avatar answered Nov 08 '22 02:11

Alain T.


Alt+Space command creates a special hidden character in Xcode files. You can see details of bug here.

For more details about solution checkout my answer on Xcode - Invalid character in source file (Replace “ ” with “ ”)

like image 25
s.zainulabideen Avatar answered Nov 08 '22 00:11

s.zainulabideen