xcodeswiftuiwwdc

How do I move a block of code with the mouse in Xcode, drag and drop style


How do I drag blocks of code, specifically SwiftUI views, around with my mouse in Xcode?

In this video https://developer.apple.com/videos/play/wwdc2020/10033/ about making widgets in swift, the author drags a block of code with his mouse. Between 4:50 and 4:57 he moves a VStack into a ZStack by nicely dragging it instead of cut and paste.

I have been searching, clicking, dragging, ctrl-shift-right-clicking, trying all sorts of things to do this. All my Google searches just come up with command+option+] or I hit how to implement drag and drop code, not how to drag and drop code, if you know what I mean.

I am using XCode 13.0


Solution

  • The secret here is you have to hold down the mouse before starting to move the block of code, and no command / alt / option trickery is needed. I was basically running down the hill when I just needed to walk down the hill.

    I will resist the urge to delete this, it seems like a dumb question now, but there must be one other person at least out there this might help.