# Platform depended script. Bug, or confusion?

**URL:** https://discussions.unity.com/t/platform-depended-script-bug-or-confusion/461625
**Category:** Mobile
**Tags:** Scripting
**Created:** [November 24, 2011, 1:48am UTC](https://discussions.unity.com/t/platform-depended-script-bug-or-confusion/461625 "2011-11-24T01:48:46Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![dangermouse](https://avatars.discourse-cdn.com/v4/letter/d/a6a055/32.png) [@dangermouse](https://discussions.unity.com/u/dangermouse)
#### Post date: [November 24, 2011, 1:48am UTC](https://discussions.unity.com/t/platform-depended-script-bug-or-confusion/461625/1 "2011-11-24T01:48:46Z")

</div>

Hi guys, I’m running a bit of platform dependant code so that I can get my editor working with the mouse, and the iPhone working with touch, using the same code.

Works fine on the iPhone, but in the editor, it appears to run BOTH.

It seems the editor is saying "Yes, this is editor code and I’ll run it. Yes, I’m deploying for iPhone, I’ll run that too.

```auto
#if UNITY_IPHONE
    Debug.Log("I'm an iPhone!");		
#endif	
#if UNITY_EDITOR
    Debug.Log("I'm the editor!");
#endif

```

It cleary prints both when I run my game in the editor.

How can I stop it running the iPhone Code, without switching the projects platform?

---

<div class="post-metadata">

### Author: ![Eric5h5](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/eric5h5/32/44225_2.png) [@Eric5h5](https://discussions.unity.com/u/Eric5h5)
#### Post date: [November 24, 2011, 2:25am UTC](https://discussions.unity.com/t/platform-depended-script-bug-or-confusion/461625/2 "2011-11-24T02:25:08Z")

</div>

[http://unity3d.com/support/documentation/Manual/Platform%20Dependent%20Compilation.html](http://unity3d.com/support/documentation/Manual/Platform%20Dependent%20Compilation.html) “Furthermore, you can run this code within the Editor, so you can compile the code specifically for your mobile/console and test it in the Editor!” It would be a problem if code intended for iOS didn’t run in the editor; e.g. you couldn’t test it with Unity Remote. You can do this though:

```auto
#if UNITY_IPHONE !UNITY_EDITOR
    Debug.Log ("Only iOS");
#else
    Debug.Log ("Other platforms");
#endif

```

–Eric

---

<div class="post-metadata">

### Author: ![dangermouse](https://avatars.discourse-cdn.com/v4/letter/d/a6a055/32.png) [@dangermouse](https://discussions.unity.com/u/dangermouse)
#### Post date: [November 24, 2011, 3:08am UTC](https://discussions.unity.com/t/platform-depended-script-bug-or-confusion/461625/3 "2011-11-24T03:08:38Z")

</div>

Aha, thank you Eric!

What you’ve said make perfect sense, that’d why I had confusion appended to my thread title.

Would be nice if the documentation had your little code snippet in it.

Thanks again
