I often check device type to have separate UI code between iOS and iPadOS. This is for the code which is not SwiftUI yet. I can check device type during runtime using UIDevice. However it's not as good as Swift pre-processor macros because pre-processor macros can assist compiler and should be more efficient without risks of C macros, decision is made before run-time which is preferable.
If you think about UI, the main condition is screen size. iPad apps are closer to Mac than iPhone. it would be great to quickly check is code running on iPhone or iPad/Mac quickly.
I have tried to use this:
This would work for iOS VS macOS, but it doesn't understands iPadOS:
Thanks for reading.
If you think about UI, the main condition is screen size. iPad apps are closer to Mac than iPhone. it would be great to quickly check is code running on iPhone or iPad/Mac quickly.
I have tried to use this:
Code Block #if os(iOS) // Code #endif
This would work for iOS VS macOS, but it doesn't understands iPadOS:
Even if would does, I don't think it's possible to write something like:Unknown operating system for build configuration 'os'
Code Block #if os(iPasOS || macOS) // Code #endif
Thanks for reading.