Does Unity support something like #if iOS?

Is there any way to do something like that:

#if iOS
  DoStuff();
#else
  Meh();
#endif

So that the not-iOS-stuff won’t even be in the compiled iOS file? I want to lock some things for the iOS version of my game, and I really dislike the idea to compile code into the .app file I won’t need a single time.

if Application.platform == RuntimePlatform.IPhonePlayer

Better:
#if UNITY_IPHONE

That way you don’t have to do the check at runtime, which will be slightly more performant.

http://forum.unity3d.com/threads/63944-Preprocessor-directives

http://answers.unity3d.com/questions/1687/what-c-predefines-are-recognized-by-unity

http://answers.unity3d.com/questions/25878/how-to-test-if-game-is-currently-deployed-on-ios

Better than Better:
#if UNITY_IOS
(old answer deprecated)
see

4 Likes