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 (screenshot below).
Do you have any idea why? Am I the only one having this issue?
EDIT: It seems to work again after restarting Xcode... Still looking from where it comes. It's a bit annoying...
EDIT2: It still occurs on Xcode 8.1. Maybe because I have 2 versions of Xcode installed (normal and beta)? Can't fix it anymore with a simple restart!
EDIT3: the proposed xpccachectl
command to fix it doesn't exist on MacOS High Sierra.
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,
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.
This still (May 2017) happens to me occasionally in Xcode 8.3.2. Quitting Xcode is not enough to clear it up. Logging out and logging back in fixed it for me. I did not have to run a command line tool or reboot.
Not to downplay the discussion above, but I tried all the solutions proposed above and all failed. Finally I updated Xcode to the latest Version 9.3 (2018) and everything works now!