Sometimes, it seems I can\'t comment my code with the usual shortcut (command
+ /
) under Xcode 8 Beta 4. The option is disabled in the menu (screen
My situation is a bit different(stupid?): I found I can't comment any line from a particular part of a particular file. I tried all the methods above with Xcode 8.1 and Xcode 8.2, but got no luck. Finally I found it was caused by a comment trick like below,
1 /*
2 code
3 //*/
4 code
In Xcode, you can't comment line 2 with Cmd+/ because it has been commented already by /**/, which is fine. However, you can't even comment line 4 with Cmd+/, as Xcode may think it's still in a /* */ block, but it's actually not. If I remove // from line 3, then commenting line 4 works fine.
Fix Xcode 8 Comment/UnComment menus: "sudo /usr/libexec/xpccachectl
" then reboot.
This works for me. Good Luck.
It seems that if you have nested /* anywhere in your code it breaks the commenting from then on. Others have reported that it happens with nested block comments. However if you have nested /* anywhere, including a string it will fail.
Note the following bit of code is working with path characters /
and wildcards *
that together make /*
. Anything after this line and commenting out doesn't work in XCode.
int foo = "this line can be commented out";
predicate = [NSPredicate predicateWithFormat:@"(cachedAudioDataURL like '*/Library/Private*/*')) AND (NOT (cachedAudioDataURL like '*/Documents/*'))"];
int bar = "broken - can't be commented out";
It still happens in Xcode 8.1 which was installed from Mac App Store.
I tried sudo usr/libexec/xpccachectl
, but no luck.
I could solve this be reassigning shortcut keys again.
Structure -> Comment Selection
menu.
You don't have to change all of them. One is enough. Command + /
again.Now it works.
sudo /usr/libexec/xpccachectl
in TerminalSource
On a German Macintosh Computer, there is a System keyboard shortcut overriding the Xcode comment section shortcut.
Simply deactivate the Hilfemenü anzeigen
shortcut. (show help)