- Home /
Get error on iPhone (Sealed Class) when trying to build iOS Game for Windows
The code:
if (Application.platform == RuntimePlatform.IPhonePlayer) {
int defaultFontSize = 32;
if(iPhone != null && iPhone.generation.ToString().IndexOf("iPad") >=0)
defaultFontSize = 64;
The Error:
Assets/scripts/GameManager.cs(133,28): error CS0103: The name `iPhone' does not exist in the current context
Please advice,
Thanks, Shefyg
Answer by asafsitner · Oct 23, 2014 at 12:42 PM
The first thing I'd do is take a look at conditional compile directives.
So instead of
if (Application.platform == RuntimePlatform.IPhonePlayer)
{
// iPhone-specific code
}
I'd do
#if UNITY_IPHONE
// iPhone-specific code
#endif
@asafsitner, i added a link to the directives in the documentation.
@Landern of course, thanks! I totally forgot to do that.
Hi, so I have Unity 5.4.3 ( $$anonymous$$ac 10.11.4 El Capitan ) and I'm getting this error when building, everything works in the editor.
#if DEVELOP$$anonymous$$ENT_BUILD
if( anyDeviceIsTestDevice )
{
#if UNITY_ANDROID
adRequest.TestDevices.Add( I$$anonymous$$EI_Handler.GetDeviceID() );
#elif UNITY_IOS
adRequest.TestDevices.Add( iPhone.advertisingIdentifier );
#endif
}
else for( int i=0; i<testDeviceIds.Length; i++ )
{
if( !string.IsNullOrEmpty( testDeviceIds[i] ) )
{
adRequest.TestDevices.Add( testDeviceIds[i] );
}
}
#endif
Hi, so I have Unity 5.4.3 and this code which throws same error when compiling even though I have the preprocessor directive defined.
#if DEVELOP$$anonymous$$ENT_BUILD
if( anyDeviceIsTestDevice )
{
#if UNITY_ANDROID
adRequest.TestDevices.Add( I$$anonymous$$EI_Handler.GetDeviceID() );
#elif UNITY_IOS
adRequest.TestDevices.Add( iPhone.advertisingIdentifier );
#endif
}
else for( int i=0; i<testDeviceIds.Length; i++ )
{
if( !string.IsNullOrEmpty( testDeviceIds[i] ) )
{
adRequest.TestDevices.Add( testDeviceIds[i] );
}
}
#endif
And yes, the code compiles in Unity Editor with no issues, the error comes when I build.
Any ideas?
For me Unity versions from 5.6.0 to 2017.1.0f1 iOS builds doesn't respect DEVELOP$$anonymous$$ENT_BUILD directive regardless of "Development Build" option is checked or not. It always skips.