If you aren’t following every little Apple announcement, you may have missed that in 2021 the company released an update to the Swift Playgrounds app that allowed for building apps on iPadOS. Swift Playgrounds, of course, is not Xcode, but provides a basic experience for creating applications that can run on iPadOS and iOS. One of the improvements that enable this additional functionality was the creation of a new “App Playgrounds” project type.

What is an App Playground?

An App Playground is a lightweight project type that is supported in both Swift Playgrounds on the iPad as well as Xcode and Swift Playgrounds on the Mac. App Playgrounds modernize some aspects of the iPadOS app development experience. The biggest improvement is the Capabilities editor. While it doesn’t have every option available in an XCode project, it presents the various capabilities and entitlements an app may use in a straightforward, easy to comprehend manner. App Playgrounds use the .swiftpm file extension, and are essentially a specially formatted folder, under the covers.

App Playgrounds support the Swift Package Manager (even on iPadOS) for importing 3rd party libraries into your project. According to an article from iosexample.com, the only Packages that can be used on iPadOS are those that are “Pure Swift” (i.e. no C or C++ code).

Required Tools

  • Xcode on macOS
  • git on macOS (GUI client or command line)
  • Swift Playgrounds on iPad
  • Working Copy on iPad
    This is a paid app, and kind of expensive, but totally worth to:
    • support an indie dev
    • have access to a great git client

This post assumes a basic familiarity with iPadOS/iOS app development and version control using Git.

I’m going to go through two sets up instructions, one if you’re starting on iPad, and one if you’re starting on Mac. At a high level, the flow is:

Create App Playgrounds Project -> Create git repository -> Commit and push project -> pull project down on other device.

Setup

iPad to Mac

  • If you’re starting your project on iPadOS, you should be aware that Playgrounds are created by default in Swift Playgrounds’ sandbox, which is exposed in the Files app.
  • I like to have a folder named “Projects” for my development projects, and on the iPad I use local storage (On My iPad) for that. In my Projects folder, I’m going to create a folder for this demo app called “Demo App”.
  • With the new Playground file created, exit Swift Playgrounds and go the Working Copy app. Describing the intricacies of Working Copy is beyond the scope of this article, but the user’s guide is worth a read.
  • Tapping the + in the top left corner should give you an option to “Initialize New Repository”. If you want to see where this repo is located by default, you can long press the newly created repository in the Repositories list and select the “Files App” option.
  • To get the new git repository to reference our Projects folder, tap on the disclosure arrow next to the name of the repository. Then tap on the option labelled “Link Repository To” and select “directory”. Select the subdirectory we created in the Projects folder. Per the Working Copy documentation, this only works with File Providers that grant folder level permissions, which would be iCloud Drive or the On My iPad options. This step isn’t necessarily a requirement, but it matches my mental model of having a folder where both my project files and git repo lives.
Shows linking git repository to Files app location
  • Now, you can copy the Project file we created earlier into the On My iPad -> Projects -> Demo App folder.
  • Going back to Working Copy, we’ll need to commit our changes and push them to the remote.
  • The project browser in the Playgrounds app only shows projects that are in its sandbox, so it is best to delete the Playground file we originally created from the Swift Playgrounds App. Open the correct App Playground from the Project folder in the files app, or from the Playgrounds app by tapping the ellipsis icon -> Browse.
Shows where to open a Playgrounds file from outside of the app sandbox.
  • From the Mac, determine what directory you want to keep your project files in. Using your git client of choice, clone the repo.
  • Open the App Playground in XCode (or Playgrounds if you wish), and you’re good to go!

Mac to iPad

  • Start by creating a new App Playground project in XCode wherever you normally create your projects
  • In the Terminal or your Git client of choice, create your Git client with a git init command. Important point: Do not use Xcode to initialize your Git repo. You need to include the entire project file in the repo, and for some reason Xcode creates the repository inside the Playground project.
  • Add the repository remote using the git remote add command
  • Push the new repo to Github or your remote location of choice
  • Switch to the iPad and clone the new repo in Working Copy
  • Link the new repo to your project folder in the Files App (see instructions from the iPad section)
  • Tap the App Playground project from the Files app and it should open in Swift Playgrounds!

Limitations

An App Playground project can be viewed as a slimmed down version of an XCode Project. However, that means that all of the capabilities of an XCode project are not currently available. Some limitations I’ve run into:

  • Lack of extension support, specifically the lack of WidgetKit.
  • No support for the Background Audio entitlement through the Capabilities editor (FB12950440). However, developer Gui Rambo detailed a workaround (in XCode) in a blog post .
  • No localization support for App Playgrounds (FB12973449).
  • As mentioned above, the project browser in the Swift Playgrounds iPad app only displays projects from the default sandbox.

Conclusion

The tools I use for my creative work are my Mac Mini at my desk, and my iPad Pro when mobile. This means that I try to utilize tools and workflows that let me seamlessly switch between those machines. If you are using your iPad for building apps, this is a way you can continue to use your Mac with the same project.

Leave a Reply

Discover more from SlatePad

Subscribe now to keep reading and get access to the full archive.

Continue reading