Programmatically identify device type iOS, iPadOS & macOS Catalyst.

If you are developing a macOS catalyst app, you may be wondering how to conditionally write code specifically for iOS, iPad OS, or the macOS 10.15 catalyst app.

Here is how to do it.

Use the code below to declare specifically written code, which will compile only for iOS and iPadOS.

#if !targetEnvironment(macCatalyst)
// Code that will execute only on iOS 13, iPadOS 13 and above

#endif

Use the code below to compile only for the macOS 10.15 Catalina Catalyst app and above.

#if targetEnvironment(macCatalyst)
// Code that will execute only on Mac

#endif

Hope it helps,

Thanks & Regards
Mandar Apte

Published by Mandar Apte

Mandar is a Mumbai-based multi-disciplinary designer with UX/UI, Logo, Symbol, and Brand Identity design expertise. He currently runs his Mudrkashar Linguistic Apple iPhone, iPad, and Mac app business in the heart of Mumbai city.

Leave a comment

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.