Can't paste into Xcode

In the past few months, I have been unable to paste text into XCode.

I can paste from xcode to xcode.

I cannot paste from anywhere else. The cursor moves the amount of characters that are supposed to be pasted, but nothing is actually pasted.

Sometimes, some of the text is pasted, but the formatting is all messed up.

Anyone have any ideas? Tried both Xcode 6.2 beta and Xcode 6.1.1

Thanks!


Solution 1:

A few things to check:

1) That you're using the correct command-line developer tools. (newer versions of Xcode 6.2+ rely on these for things like SourceKit etc..)

You can check this by running xcode-select -p in terminal, and you should get back something to the tune of /Applications/Xcode.app/Contents/Developer or the path to whichever beta you're using i.e. /Applications/Xcode-beta.app/Contents/Developer

2) Don't rename the beta-s i.e. '/Applications/Xcode-beta.app' to '/Applications/Xcode-6.2-beta4.app'. Things go awry with this!

3) Is your pboard working in general?

Drop to terminal and:

  • ps -ef | grep pboard

should come back with something such as:

504 367 1 0 2:20pm ?? 0:00.01 /usr/sbin/pboard

if it doesn't, double confirm that it's set up to be launched properly by:

launchctl list | grep pboard

this should come back with something like:

367 0 com.apple.pboard

Note the 367 shown in both for the PID. This basically indicates that my pboard is running fine...

If you get something else try:

cat /System/Library/LaunchAgents/com.apple.pboard.plist

and you should get something like:

...
<plist version="1.0">
    <dict>
        <key>POSIXSpawnType</key>
        <string>Interactive</string>
        <key>Label</key>
        <string>com.apple.pboard</string>
        <key>ProgramArguments</key>
        <array>
            <string>/usr/sbin/pboard</string>
        </array>
        <key>MachServices</key>
        <dict>
            <key>com.apple.pasteboard.1</key>
            <true/>
        </dict>
        <key>EnableTransactions</key>
        <true/>
    </dict>
</plist>

4) When you paste into Xcode, and you get the spaces (i.e. missing characters), when immediately save the document, is the text there after restarting Xcode and reloading the project?

5) If you open Console in (Applications/Utilities/) do you see anything specific flashing up when you paste? i.e. any Xcode, DVT, SourceKit, Pboard etc... assertion errors etc.. - try pasting whilst console is open so you can see this. - (the above tags I listed should be good filter words for console)

Let us know if this helps :)

Solution 2:

Perhaps not a solution, but a workaround.

How about using Kill & Yank instead?

Ctrl ⌃ K to cut/kill
Ctrl ⌃ Y to paste/yank

It differs from copy/paste in that if you have no text selected, it will kill to the end of the current paragraph by default.
There's no equivalent to Copy, if you want to keep the text you just killed in its original location you have to yank it back into its original place first, or Undo.