Swift Playgrounds 4.0 Update review
INTRODUCTION OR HOW I MET YOUR IPAD
Swift Playgrounds 4 has been on my mind since it’s announcement at WWDC. I’ve talked about, tweeted about and otherwise gabbed on and on about coding on the iPad. I’m very much a fan of the iPad and it’s capabilities and want to see REAL mobile development for iOS devices exist on the iPad.
Well it seems that someone at Apple heard my excitement, fervor or whatever else and decided to let me try the Swift Playgrounds 4.0 update for the last month, and I have some opinions and observations that I figure I would share with anyone willing to read this. Please note, I’m not a professional reviewer of software, but I’ve been vocal enough about it on social media I feel like I’m entitled to share this with you all so….buckle up.
If you don’t have time to check out the whole thing the TL:DR is this - I love it, BUT there are many things that I’m excited for that could make it even better in the future. Read on if that little tidbit raised your eyebrows.
For those who don’t know what Swift Playgrounds is, it’s basically a teaching/learning tool for those beginning in Swift/iOS app development to learn how to code. It teaches basic principles and allows for some code to be written, however it’s not geared as a full fledged “App Development Suite” the likes of Xcode or any other IDE would be in other languages.
Swift Playgrounds 4.0 is set to change all of that, or at least lay down the foundations for this change, and start letting users develop full blown apps on the iPad. During WWDC 2021 it was shown on stage for a brief moment highlighting how a user could develop on the go with their favorite Apple tablet of choice, even better it was something that could be used even on older iPads as long as they supported iOS 15.
So with that little explainer out of the way lets talk nitty gritty. The moment that WWDC 2021 was over I was excited and purchased an iPad Air 2 off eBay with the express purpose of testing Swift Playgrounds 4.0 on it as soon as it came out. Armed with this device and my iPad Pro 2021 I installed iOS 15.2 beta (the required OS version for Swift Playgrounds 4) and got to testing.
HOW I TESTED THIS THING
The best thing, I thought, would be to try and build an app and see how far I could get and what roadblocks I would run into. This birth my first (hopeful) released app “Munchi” for tracking and sharing my favorite orders for restaurants. It’s small, simple but has enough complexity to hopefully push Swift Playgrounds 4 to its limits.
Loading into the app after applying the update I was greeted with the standard Swift Playgrounds interface, but with a new button titled “App” in the “More Playgrounds” section, as well as a compose button. Pressing both brought me to a new interface.
The interface itself is very touch friendly, with a large collapsable menu on the left for my files, a canvas in the middle for writing code and an app preview on the right. The very first thing laid out for me is a SwiftUI view (Apple’s new interface of choice) and nothing but my mind’s options laid out in front of me.
I decided to attempt to build an app that fit these functions:
Can I build in SwiftUI? UIKit? AppKit?
Is it possible to pull in other Xcode projects and work on them?
Github/repo integration?
Can I use Core Data or some form of persistence?
What packages can/can’t I install?
How easy is it to pickup in Xcode and continue?
THE CONS
Can I build in SwiftUI? UIKit? AppKit?
The first question was quickly answered, yes you can build in SwiftUI or UIKit, however the target app is decidedly for iOS/iPadOS. Don’t think about making an Apple Watch app, a Mac App (unless it’s catalyst based but I will get to that shortly) or any Apple TV apps. Swift Playgrounds 4 is very much iPhone/iPad ONLY.
Is it possible to pull in other Xcode projects and work on them?
Following down the list I tried to pull in a few small Xcode projects I was working on but with no luck. As Aaron Sky (@metc_sky on Twitter) pointed out in this article: https://skyaaron.com/posts/swiftpm-app-projects/. (Seriously go give this a read, it will help clear up more technical stuff) The new .swiftpm package type is essentially how the project is made. This isn’t your standard .xcodeproj or workspace. You can absolutely pull in .swift files into the project, but once pulled in they become the property of that project. Somewhat disappointing, but it kinda makes sense due to the other limitations (which I will touch out in a moment).
Github/repo integration?
Moving forward on the list, Github/repo integration are a no go. Don’t expect that you can pull down a repo directly through Swift Playgrounds 4 and start working on it, nor should you expect any sort of Git control at all. If you want to save or share your progress, maybe create a fork of the work you are using you will have to move the file to your Mac (either via iCloud or other means) and then work on it from there. You may be able to use something like Working Copy or any other Git management apps but I have no experience with them. Use at your own risk.
Can I use Core Data or some form of persistence? What packages can/can’t I install?
So Core Data and Persistence are interesting. You cannot add Core Data to your project, nor could I get Realm working via the package installer, however you could use @AppStorage, @SceneStorage and UserDefaults. Since these are more “Standard” packages they are great for small apps with non-critical data but I would expect anything beyond that. Package installation could be applied here as well, I didn’t get a chance to install any packages with this project as most of the packages I tried to install were either not updated or weren’t supported in some way or another. Bummer! I’m sure as packages mature we might see more become available. The option is there, but overall it’s more or less due to the limitations.
How easy is it to pickup in Xcode and continue?
The last bit, moving the project to Xcode was easy enough…but not in the way I would have liked it. It moves over just fine via iCloud and I had no problem opening it up with Xcode 13.2 beta (required due to the new .swiftpm file type) but getting it integrated within any projects or to start adding more mature features was a nightmare. I tried importing it as a regular package into a new project, I tried just building a new project on top of this….thing and I tried just importing it as files and it still wouldn’t budge. I ended up copying the files over directly into a new project from there in order to get the backend part of the app done.
“BUT FRANK”, you exclaim loudly and with some irritation,”YOU SAID YOU LOVED THIS UPDATE, WHAT’S WITH THE NEGATIVITY AND ALL THE LIMITATIONS?”. A fair point and to that I say…just…ok. There are a lot of criticisms, especially as someone with many many hours of Xcode under my belt. This update is NOT perfect and is missing a lot of stuff. I can also imagine more seasoned developers not feeling too keen on all of these missing features, however let me go over the pros so you can weigh for yourself.
THE PROS
Now first of all the interface is FAST with a capital F. To make a comparison on speed, the app preview on the iPAD AIR 2 shows a preview in a matter of seconds compared to the BRAND NEW MACBOOK PRO WITH M1 PRO trying to show a SwiftUI preview. It’s also fully functional the moment it’s ready, meaning that you can start scrolling, tapping and otherwise jumping around the app no problem, mere SECONDS after you have written the code. On the 2021 iPad Pro I have it’s near instant. You can write something and immediately start playing around with it or see the changes. This alone is a GAME CHANGER for development iteration for design and function. You can see immediately how quick things change.
This may sounds stupid and not so much a feature as well, but having ONE app that does ONE thing in front of me made me more productive right off the get go as well. Not having a million little things going on or grabbing your attention made for a far more compelling use case. I also managed to carry my 12” iPad around and it was far more comfortable to work on. The versatility of sketching something up, quickly coding it and then snapshotting that change to markup some more is incredible.
I can also see the incredible backwards compatibility for those who don’t have the budget for a new setup and want to actually start coding. Since the environment is “good enough” for basic UI work and some simple data persistence (or API access) you could in theory make an app from front to back on this thing and the barrier to entry is vastly cheaper than a MacBook Pro. If you wanted to go EXTREMELY CHEAP and buy an iPad Air 2 and a form of keyboard you could do so for sub-$200 and start making and uploading apps (since that ALSO can be done directly from the iPad).
All in all I see these options as strengths. Getting more people into code, making the playground more versatile and giving us some starter options is fantastic. I really hope Apple sees benefits however to adding more feature support. CoreData, easier transferal to full blown app projects and more SPM projects getting updated would be nice. More project control and file type imports as well.
With all that said I’m glad you stuck around to the end. Please check out Munchi on the App Store or via my TestFlight HERE, whichever come out first. Ask me questions or comments on this article on my Twitter @frankefoster