xcodexcode14

How can I copy the code samples from Xcode (14.x) Library window


When I open up the Library window in Xcode 14. and click on a particular control like the Picker, I see code samples for using the particular control.

I can highlight the sample code text and right click it and choose [Copy] from the context menu (see image).

Xcode Library Code Sample for Picker

However, when I do that:

  1. the context menu flashes away.
  2. the Library window disappears

Sample Code Doesn't Paste In

Then when I go to Xcode to paste the text in, the sample code does not appear. Instead, I either get nothing pasted in or the last thing I copied is pasted in.

And, yes, copy / paste works everywhere else on my mac with no problems.

How can I copy that code sample?


Solution

  • The only way I could ever copy that sample code was to :

    Choose Share -> Notes (see image)

    Then open notes and copy it from there and it successfully pasted into Xcode.

    Xcode Share to Notes Context Menu

    Update: Additional Way To Get Code Sample

    I was back in Xcode and I happened to scroll all the way to the bottom of the Picker documentation entry and I found a link that will open the document in Developer Documentation (see red highlight in image).

    Open In Developer Documentation link

    If you click that link then Apple Developer Documentation window opens and you can copy the sample code.

    apple developer documentation