I offer an iOS app on the App Store. With the launch of Apple's M1 Macs it's possible to run iOS apps on macOS. I want to prevent that my app is used on macOS, for example by throwing an exception after launch or calling exit(0)
at a later time.
How can I detect that the app is running on an M1 Mac?
To a certain extent, iOS apps running on Macs seem to report themselves as iPads1, so this rules out some common ways to identify the device.
Some details to provide context:
I already removed the app from the Mac App Store on App Store Connect.
The app is made and optimized for touch screens. The current version would offer a very bad user experience when run on macOS. It would require many changes and a lot of effort to make it a good Mac app. I don't have any plans, let alone the resources to do that.
On the surface this might seem similar to the question "How can I detect if my app runs on a jailbroken device?". Technically, this might be correct, and I understand that it's generally not advisable to implement jailbreak detection to prevent IAP hacks etc. An important difference is that Apple is actively trying to prevent jailbreaks and strongly discourages users from doing so, which seems to keeps the jailbreak community rather small and off mainstream, but on the other hand, Apple obviously wants to have as many iOS apps as possible available on Macs. It's currently very easy to run iOS apps on Macs, even if they are not offered in the Mac App Store. There are instructions on popular tech blogs like MacRumors and 9to5mac. I want to make sure that at least this easy way to run the app on a mac is prevented.
Many implementation details in this app have been developed under the assumption that the app will only ever run in an iOS sandbox that users don't have easy access to. Now, it's probably much easier for users to run the app with modified resources, user defaults or contents of directories like
Application Support
, including files that I assumed to be always immutable. If users find a way to access content in the app that usually requires in-app purchases or subscriptions, for example by fudging.plist
s or renaming resource files in an unexpected way, it's a real business risk.
1 At the time of the original post, M1 Macs appeared to report themselves via hw.machine
as model identifier iPad8,6
. A tweet that provided a few more details has since been removed.