top of page
Search
Writer's pictureOm Chachad

How to Restrict a Swift Playgrounds App to the iPad Platform only?

I recently launched my app, Pencilera, built entirely on iPad. In an earlier post, I discussed about the pitfalls and upsides of building an app on iPad Swift Playgrounds. If you aren’t aware already, Pencilera is an app exclusively for iPad that turns your Apple Pencil into a camera remote; evidently, this app won’t really serve any meaningful purpose on an iPhone or Mac. You can choose not to publish the app on the Mac App Store via App Store Connect, but since iOS and iPadOS use the same app binaries, there’s no real option on App Store connect to disable your app for iPhone or iPad and has to be configured inside Xcode or Swift Playgrounds.


However, Swift Playgrounds has no option to restrict the app to iPhone or iPad, it defaults to supporting both. This could be detrimental to an app like mine, but turns out, you can hack your way into adding this restriction to your app.

I’ll be showing two methods to do this, the first requires a Mac, and the second one can be done entirely on iPad.


Let’s start off with the method with the Mac.


If your Swift Playgrounds file (.swiftpm) is located on your iPad, find it in the Files app and then AirDrop it to your Mac.


On your Mac, locate the file you just AirDropped or locate it directly from your iCloud folder. Right click on the .swiftpm file and click Show Package Contents.


Locate the Package.swift file inside the Package, right click and open with TextEdit or Xcode. For demonstration purposes, I am going to stick to TextEdit, but if you have the Xcode app, you’re probably smart enough to replicate it in Xcode, haha!



In the array of ‘supportedDeviceFamilies’, you’ll see .pad, and .phone. Get rid of .phone or .pad depending on what your requirements are, and the one that remains is the one that your app will support.

And that’s it! Just AirDrop it back to your iPad, and get back to coding.



iPad Method

If you don’t have a Mac, use an app called Working Copy. Now this app is actually meant as a version control system to sync your project with GitHub, which by the way is a great tool if you’re building with Swift Playgrounds on iPad, but it also comes with the ability to edit files inside your project. So, here’s what you have to do.



Open the Files App and Working Copy in Split View or Stage Manager, and locate your .swiftpm files inside your Playgrounds folder (likely inside iCloud Drive).

Drag and Drop your file into Working Copy.


Your package contents should now be populated! Look for the Package.swift file, and tap on it.

In the array of ‘supportedDeviceFamilies’, you’ll see .pad, and .phone. Get rid of .phone or .pad depending on what your requirements are, and the one that remains is the one that your app will support. Click the Checkmark on the top right once you’re done!


That’s all you need to do! The next time you push to App Store Connect, you will only have to upload screenshots for the platform you chose, and users on the excluded platform will not be able to install the app on their device via the App Store or via TestFlight.


I hope this helped you out! I'm working on releasing Pencilera v2.0 this week, so stay tuned for that announcement over on Starlight Apps LLP. I wasn’t able to post last weekend, I’ve been super busy since I have exams going on right now, but I’ll be back to weekly posting next week onwards. I’ll see you then!

Comentários


bottom of page