Time for some crystal ball gazing with my wish-list/ predictions for a future version of Swift Playgrounds. The top 5 are things that would change the scope of what a playground could be quite dramatically, the rest is more minor stuff. A couple of these items might be unlikely to happen, but most are feasible, I think.
Edit auxiliary source files
As well as being a great way to organise your code, auxiliary files aren’t subject to playground logging, so they perform much better than the main
Contents.swift playground file. Currently we can only view auxiliary files in-app.
Edit property lists
Manifest.plist file allows you to implement all kinds of good stuff, such as edge-to-edge liveview, and the ability to turn off playground logging for better performance. Currently you can’t view or edit these files in-app. Together with number 1, this would allow full playground books to be authored in-app.
Distribute playground books
We don’t know yet what kind of distribution model Apple has in mind for Xcode-authored playground books, but the app’s “Featured” page looks very much like an iBooks/ App Store store front. Will it be a monetized store, or will it stay free?
Add entitlements to a playground
Actions that in the context of an app would require entitlements fail silently in playgrounds. So in a playground you can’t, for instance, use
CLLocationManager to discover the device’s geographical location. It seems a shame to exclude these actions from playgrounds. I’ve no idea how this would work, but it would be great if there was some way to add entitlements to a playground (perhaps by adding them to the
Manifest.plist?) Or only allowing these actions to be called from user-entered code in
Contents.swift, and not from an auxiliary source?
Use playgrounds to “script” iOS via action sheet extensions
One of the most incredible features of Pythonista is the “Run Python Script” action sheet extension, allowing you to run scripts on text, images, and URLs, or just open a Python console, from almost anywhere on iOS (see image at top). Being able to do something similar with Swift Playgrounds would be incredible. Swift isn’t an interpreted language, but given how quickly Playgrounds can compile and run it, it could in effect be used as a scripting environment. Not sure how likely/ feasible this one is.
Add extra pages to a playground chapter
It would be nice to be able to add extra pages to a given chapter in a playground book from within the app. These would have access to the auxiliary files scoped to that chapter, and could be used as scratch pages for the user to further explore that chapter’s topics. For this to work the chapter would need to provide some kind of blank template file to be duplicated whenever the user adds a new page.
Navigation within a file
Playground files can get pretty long. It would be nice to be able to jump to a certain method or
// MARK: point by tapping on the title bar to open a navigation menu, like we can in Xcode (and Pythonista, see image).
Full gamut colour picker
Colour literals are fantastic, and the pre-selected range of colours Apple currently provides in the picker are very tasteful, but often I need to access the full gamut. Of the various iOS colour pickers I use, I like the Adobe-style one in Codea, and Paper’s mixing wheel. Or perhaps it’s time for a system-wide colour picker on iOS?
Previews of more types of asset
Being able to import assets such as 3D
dae files from your Dropbox or wherever is really great. It’d be nice if the resource browser could show you an interactive preview of these models, like in the macOS Finder or Xcode.
Code editor Dark Mode