iPhone Syntax Causing Script Errors in Normal Unity

I am working on a project that will need to be deployed on multiple platforms (web, iOS, potentially Android). In Unity 2.6 and Unity iPhone 1.7 I’m running into a weird disconnect. Any scripts which reference iPhone functionality are creating compile errors in regular Unity.

I’ve tied to silo all my iPhone specific code as much as possible, but I just want Unity 2.6 to ignore it when I’m working on the web version. Short of waiting for Unity 3, which supposedly makes this problem go away with an integrated environment, is there a workaround for 2.6? Can I copy a DLL or something over from v1.7 of Unity iPhone?

use #if UNITY_IPHONE … #else #endifto encapsulate your iphone code.
that will solve it

You will need that anyway cause to be interesting on the iphone, your project must use native functionality in one or more way, be it only openfeint or something similar and to handle such stuff, above is the only reasonable way

Many thanks - that worked great, though I wish MonoDevelop didn’t color everything inside the #if green. :? Why must it taunt me so?!

Out of curiosity, where are constants like UNITY_IPHONE defined in the documentation? How did you know about it?

they aren’t documented to my knowledge … know of them from experience.

the only other is #if UNITY I think to check if you are on desktop - web

There is mention within the Beta Docs if you have U3 Beta. Check under ‘What’s New’ → ‘Platform Defines’

There are an increasing number of them.