Xcode 8 Beta 4 - Comment Shortcut Disabled
Asked Answered
K

12

116

I just updated to Xcode 8 Beta 4 and the shortcut cmd + / to comment a line is not working..

In the dropdown menu it's disabled:

enter image description here

There's a way to activate it again?

Kowalczyk answered 2/8, 2016 at 5:29 Comment(7)
I've just upgraded from Beta 3 to Beta 5 and experienced this issue for the first time. Quitting and reopening XCode fixes it for me, at least temporarily.Erudite
Xcode 8 Beta 6 - same issue here...Restrained
How did u get the dark theme for xcode?Hermaphrodite
@KumarC  > System Preferences > General > Use dark menu bar and dock :)Kowalczyk
Fixed (for me) in Xcode Version 8.1 (8B62) - released ~Nov 1, 2016.Ancheta
Fixed in v 8.1 after update, tool installation, and restart of Xcode.Myosotis
It can be related to a macOS update, not to Xcode. Fix here: https://mcmap.net/q/189403/-multiple-line-comment-in-xcode-8Harmonize
E
166

I fixed it following the steps here: https://twitter.com/kolpanic/status/763323546814844928

In Terminal: sudo /usr/libexec/xpccachectl

Reboot your system.

Eulau answered 25/8, 2016 at 2:35 Comment(16)
I think we have a winner! this solved my problem. I have tested all other workarounds, none worked. Thanks for sharing.Scalise
I believe it activates the new Xcode 8 Source Editor Extensions developer.apple.com/videos/play/wwdc2016/414Eulau
@DanielStorm the systemEulau
This is astounding. It was broken in the betas but I expected it to resolve itself by the time the public release went out. In a public release of an IDE we have to punch a cryptic command into shell and reboot to get code comments to work! Comeon! /minirantPlaysuit
Above solution not worked for me xCode Version 8.1 beta (8T29o). Any other suggestions?Mal
Same here. It does not work for Version 8.1 beta (8T29o)Garges
If you have release and beta Xcode -> I renamed Xcode beta app to "Xcode81.app", quit the Xcodes, then run the command in terminal and it worked finally, unless you start the beta, then need to rename again and repeat.Trillium
@Arthur I just needed to rename the beta after running the command then restarting xcode. Didn't need to run the command and/or reboot again.Gilli
With Xcode 8.1 , it works after reboot. But the after macbook's sleep it isn't working and wants again terminal and reboot. Any solution?Alkylation
See my answer if this still doesn't work for you on OS X 10.11.Cumbrance
Just started with xcode, the first thing I was looking for is to comment a line, and it's not even working. Unbelievable.Hotien
I'm sure some guy at Apple is doing this on purpose. Just laughing at all the work arounds. Cheap thrills indeed. Block comments is just such a fundamental for any IDE...Bellboy
Thanks this problem was occurring in Xcode Version 8.2.1 (8C1002) also. and above solution worked like charmKiva
I partially agree with Saleh, but unfortunately it came back the next day. This is getting very frustrating.Welbie
Worked for me without a reboot. OSX 10.12/8.1Crease
You know the worst part, there's a shortcut in the touch bar of the new MBP to access this command, but they couldn't fix the bug, still not working and need to do this sometimes.Plastometer
C
99

If Cmd-/ still doesn't work in Xcode 8 on an OS X 10.11 (and apparently on a macOS Sierra - thanks to @DanBlakemore), and sudo /usr/libexec/xpccachectl and a reboot didn't help, try the following.

  1. Close Xcode.
  2. Open /Applications in Finder, and rename Xcode.app to Xcode2.app (or any other name).
  3. Rename it back to Xcode.app, and relaunch.

It should work now.

The problem seems to be that for whatever reason the system "uninstalls" Xcode extensions at some point, and won't "install" them again. This can be checked by opening Console, and grepping for INSTALL. If you have INSTALLED/UNINSTALLED for com.apple.dt.XcodeBuiltInExtensions, it won't work if UNINSTALLED was the last action on it, and will work it if was INSTALLED.

Figured this out when debugging an Xcode 8 extension.

Cumbrance answered 16/11, 2016 at 14:12 Comment(9)
Still broken for me, unfortunately.Borderland
This works for when this happens on Sierra (10.12.1) and Xcode 8.2. It also works without a restart, which is nice as I have achieved perfect window placement and must preserve it. Does anyone have a radar for this yet?Fifi
@Fifi thanks for the info, I've updated the answer.Cumbrance
Crazy that this works, thank you so much for figuring this outMccallion
What should i type in console to check is it installed or not?Merwin
This is better than the currently 'accepted' solution because this doesn't require a terminal command or a reboot. Worked like a charm for me. Thank youHitlerism
This issue was still found in Xcode 8.3.2, I fixed it sudo /usr/libexec/xpccachectl and rename Xcode.app steps without reboot just now.Auliffe
It worked for me after I tried to install clang-format for Xcode8 (I use El Capitan 10.11.6 and Xcode 8.2). Thanks!Umbrian
Works for me. Thanks.Carpentaria
B
8

The script mentioned above didn't work right away for me. I had Xcode 8 and 8.1 GM installed and was working with both of them off and on. I ran the script in the terminal, restarted my computer, opened Xcode and it still didn't work. So then I created a new directory in Applications and moved the GM into that directory. That seemed to fix it.

TL;DR If you have multiple versions of Xcode installed:

  • Run in terminal: sudo /usr/libexec/xpccachectl
  • Restart your computer
  • Create a new directory in Applications
  • Move the other version into that directory
  • Restart Xcode and enjoy!
Billhead answered 28/10, 2016 at 22:48 Comment(1)
#thanksapple. Making our Swift 3 conversion that much more fun... This was driving me nuts for a few daysAstraddle
C
5

As explained there, here's a solution that doesn't require a reboot:

  1. Close Xcode
  2. In the Application folder, rename Xcode.app (or similar) to Xcode2.app. You might need to type in your password.
  3. Open Xcode, then close it.
  4. Rename Xcode2.app back to what it was before.
  5. (Optional) Spend 5 minutes wondering why this worked.
Camellia answered 9/8, 2017 at 10:21 Comment(0)
B
4

Just update to Xcode8 release, then open Xcode8 and restart Mac.

https://developer.apple.com/library/content/releasenotes/DeveloperTools/RN-Xcode/Introduction.html

To use the Editor's Comment/Uncomment Selection and Add Documentation commands—as well as other installed Xcode Extensions—on OS X version 10.11, launch Xcode and install additional system components, then restart your Mac. (26106213)

Benner answered 19/9, 2016 at 8:5 Comment(0)
M
3

Go to App Store, check for system update(iTunes, MacOSX). Update all of them.

It should be fixed once its done.

Mitsukomitt answered 5/8, 2016 at 10:14 Comment(1)
Just updated the OS.. in the Editor menu now I can see Comment Selection active.. but it doesn't work :(Kowalczyk
M
2

I rebooted, now it is working.

Then when I started beta 4 it asked me to "install required components" a second time. Don't know if related or not.

Mozellemozes answered 2/8, 2016 at 12:24 Comment(1)
This worked for me with the released version of Xcode 8.Paapanen
A
2

I applied @junjie 's method

sudo /usr/libexec/xpccachectl

It works well on Xcode 8.2.1 (8C1002) only except for specific files.

Then, I found the reason.

/* Comment ... //*/

This type of comment has made it inoperable.

After the line containing above comment type, "Comment Selection" didn't work.

Erase or change them.

Ammunition answered 22/12, 2016 at 6:58 Comment(0)
G
0

xcode->preferences->key buildings-> filter, search comment

see if there are conflicts for key of "command + / ", if yes, delete others unless "Comment Selection"

enter image description here

Gittens answered 16/11, 2016 at 8:17 Comment(0)
L
0

This made it for me:

Goto System Preferences -> Keyboard -> Shortcuts -> App Shortcuts

Add a new shortcut like this:

enter image description here

Voila! It works for me!

As you can see the shortcut you choose will also end up besides this command in Editor menu in Xcode.

enter image description here

Lefton answered 10/1, 2017 at 21:40 Comment(1)
Not work now work....!! I cannot figure it out anymore. xcode developers gave me big agony. :(Nannana
W
0

Before doing any of less or more complicated steps,

Try to quit and relaunch Xcode.

In my case, it has helped.

Whorled answered 28/1, 2017 at 13:20 Comment(0)
W
0

xcode->preferences->key buildings, or,

"command + ,", then search "comment selection" change the key "command + /"

Waistband answered 12/5, 2017 at 3:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.