With the latest changes in Xcode 7.3, you can once again build drag-and-drop playgrounds to provide simple Swift-based utility apps with minimal coding.
Unlike older solutions, XCPlayground’s interactive live views don’t require pop-up windows. You don’t have to do anything special to make the page application run with a different priority. Just open the assistant and the app is there, running, and interactive.
I’d really like to see Xcode drop the “open the assistant view” requirement at some point and let you embed into the main playground. For now, though, you need to set up Xcode and display the main timeline, the assistant, and typically the console, all at once.
My drag-and-drop implementation is pasted over at gist.github.com. The samples consist of three files. Place the main DropView code into the shared playground folder and add the two examples to new playground pages.
My DropView builds a drag-supporting text field. A text fields makes it easy to add the “drop here” label. The view registers for drag operations in its initializer and calls a settable handler with a list of file paths.
The example pages consist of nothing more than creating a view, setting its prompt, and adding a handler for the file paths. You can tweak the handler however you like, as user-supplied dropped paths aren’t sandboxed away from you.
I’ll be updating Playgrounds with the new examples, probably within the next week.
Comments are closed.