title: How to detect if an iOS app is running on an M1 mac?
body: <p>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 <code>exit(0)</code> at a later time.</p>
  <p><strong>How can I detect that the app is running on an M1 Mac?</strong></p>
  <p>To a certain extent, iOS apps running on Macs seem to report themselves as iPads<sup>1</sup>, so this rules out some common ways to identify the device.</p>
  <p>Some details to provide context:</p>
  <ol>
  <li><p>I already removed the app from the Mac App Store on App Store Connect.</p>
  </li>
  <li><p>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.</p>
  </li>
  <li><p>On the surface this might seem similar to the question &quot;How can I detect if my app runs on a jailbroken device?&quot;. 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 <a href="https://www.macrumors.com/how-to/install-any-ios-app-m1-mac/" rel="nofollow noreferrer">MacRumors</a> and <a href="https://9to5mac.com/2020/11/18/how-to-install-iphone-ipad-app-m1-mac/" rel="nofollow noreferrer">9to5mac</a>. I want to make sure that at least this easy way to run the app on a mac is prevented.</p>
  </li>
  <li><p>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 <code>Application Support</code>, 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 <code>.plist</code>s or renaming resource files in an unexpected way, it's a real business risk.</p>
  </li>
  </ol>
  <hr />
  <p><sup><sup>1</sup> At the time of the original post, M1 Macs appeared to report themselves via <code>hw.machine</code> as model identifier <code>iPad8,6</code>. A tweet that provided a few more details has since been removed.</sup></p>