0

Essentially what the subject says. I'm getting conflicting information from AI tools on this subject.

asked Sep 3, 2025 at 17:32

1 Answer 1

3

And to answer my own question, after experimenting with both I realized that there is in fact a huge difference between the two:

  • #if IOS will target only iOS devices (iPhones)

  • #if __IOS__ on the other hand will target iOS and MacCatalyst (and possibly other stuff like TvOS, WatchOS, ...)

I find the __IOS__ approach very misleading and dangerous for my taste and here's why. We had a piece of code that was like this:

#if __IOS__
 // do stuff
#end

We then wanted to add special handling for other apple stuff like MacCatalyst. So we tried:

#if __IOS__ // this matches both iOS and MacCatalyst!
 // do stuff
#elif MACCATALYST // wops! this will not be honored because the first #if above already matched MACCATALYST!!
 // do stuff for MacCatalyst
#end

Going forward I will be siding with the explicit approach to avoid such pitfalls

#if IOS // now I know this will only match iOS and nothing else
 // do stuff
#elif MACCATALYST
 // this will now work
#endif

Hope this helps folks out there save a few hours worth of headaches.

answered Sep 3, 2025 at 17:32
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.