Playgrounds >= Xcode
I gave a talk at /dev/world in May 2024 that put forward an argument that Swift Playgrounds is a much better featured and more useful tool than many are aware of. It has evolved since it was first released and is now capable of a whole lot more. I also suggested if we are to see development natively on Apple Vision Pro, then it’s much more likely to come in the form of Playgrounds than Xcode.
Xcode obviously isn’t going anywhere, but I can imagine that the “new” project has a quicker path to new features and improvements over dealing with the legacy and enormity of a 21 year old codebase.
You can listen to the full 25 minute talk here, or continue reading for the summary of my arguments.
Simple Beginnings
Swift Playgrounds has come along way since its inception 10(!) years ago. Marketed as an education tool, known as a scratchpad for toying with ideas. However since version 4, it’s been possible to develop and release full applications, turning Swift Playgrounds into a full IDE.
The first improvement of the Playgrounds approach is your project is packaged up into folder. Consisting of a package.swift, which defines the details of the application, a much cleaner approach than the PBX project file from an Xcode project. In fact a brand new Playground contains 45 lines of understandable swift vs 350 lines of complexity.
The second argument is that it’s not Xcode. There’s something about working in Playgrounds on the iPad that feels different to coding the same project in Xcode on a Mac. As Josh from Apple states “it’s so much fun”. The interface has been rethought for touch, with much better support for adding capabilities, colours and SFSymbols. Capabilities wise the support is broad and many common and even uncommon frameworks are supported, such as Camera, Bluetooth and even AR.
Limitations
Playgrounds is not without its limitations, it doesn’t have a debugger, there’s no support for XCTest, no inbuilt version control. Currently you can only build iOS, iPadOS and for Mac (via Catalyst). It’s missing support for WatchOS, tvOS and visionOS. The error reporting is poor (it inherits SwiftUI’s meaningless errors) and sometimes overly complex views will simply timeout rather than preview.
But the speed…
It’s certainly not enterprise ready, but for me the benefits outweigh the limitations for the majority of projects that are currently developed in Xcode. The ability to work on an iPad, open on the same project in Playgrounds on the Mac (immediately(ish) via iCloud), and even open the package in Xcode to unlock some of those missing features is key. Beating that is having a native preview that’s not via a simulator. On an M1 iPad Air, it’s near instant App previewing. Not just view previewing like the buggy and slow SwiftUI Previews in Xcode, but full app rebuild, keeping State and updating the app in near real time. Throw in system level integration with Accessibility settings and testing is a breeze.
The speed and iteration time enabled by this workflow is game changing and I can’t imagine how an M4 iPad performs. Once you add in the ability to integrate with the camera, Bluetooth and Core Motion that are only possible or practical on a physical device there are test cycles that are boosted 10x compared to the slow build and run you’re used to on Xcode.
Scholarships
But don’t take my word for it Apple has been running a scholarship challenge every year for WWDC asks to submit a playground as their submission over the years. Examples of these have been collected and shared. Over on WWDCscholars.com you’ll see so many more examples of what’s possible when a lot more talented people than I can get hold of this tool.
I sure hope at this years WWDC we’ll see more focus on this under represented tool in Apple’s toolbox. Although I expect it’ll need a name change before it’s taken seriously.
“Xcode HD” anyone?