iOS namespace not found in unity engine

I need to check the device type in my code. I use a line like:

return UnityEngine.iOS.Device.generation.ToString().IndexOf("iPad") > -1;

This compiles in the editor but on building an executable, I get an error - The type or namespace iOS does not exist in the namespace UnityEngine. I assume this is because I am building something for a windows platform, so iOS is not recognized. The app needs to be able to function on multiple platforms and it needs to know what platform it is on, so how do I get this to compile on windows?

Found a solution. Easiest way to go is with the following code:

#if UNITY_IOS
        return UnityEngine.iOS.Device.generation.ToString().IndexOf("iPad") > -1;
#else
        return false;
#endif