ArgumentOutOfRangeException thrown by compiling for iOS Simulator SDK

After switching the Player iOS configuration to use “Simulator SDK” as the Target SDK for iOS, the project suddenly fails to compile while giving an ArgumentOutOfRangeException while in the default PostProcessiPhonePlayer code. The project compiles fine when not set to Simulator SDK. The version I am using is 5.4.1p2. Is anyone else having an issue getting Simulator SDK to work? Below is the full stack trace.

ArgumentOutOfRangeException: Cannot be negative.
Parameter name: length
System.String.Substring (Int32 startIndex, Int32 length) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/String.cs:348)
UnityEditor.iOS.PostProcessiPhonePlayer.PostProcess (BuildTarget target, System.String stagingAreaData, System.String stagingArea, System.String stagingAreaDataManaged, System.String playerPackage, System.String installPath, System.String companyName, System.String productName, BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry) (at /Users/builduser/buildslave/unity/build/PlatformDependent/iPhonePlayer/Extensions/Common/BuildPostProcessor.cs:399)
UnityEditor.iOS.iOSBuildPostprocessor.PostProcess (BuildPostProcessArgs args) (at /Users/builduser/buildslave/unity/build/PlatformDependent/iPhonePlayer/Extensions/Common/ExtensionModule.cs:27)
UnityEditor.PostprocessBuildPlayer.Postprocess (BuildTarget target, System.String installPath, System.String companyName, System.String productName, Int32 width, Int32 height, System.String downloadWebplayerUrl, System.String manualDownloadWebplayerUrl, BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.BuildReporting.BuildReport report) (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/PostprocessBuildPlayer.cs:176)
UnityEditor.HostView:OnGUI()

Update: this issue had been plaguing us for several days while trying to run xcodebuild tests from a Simulator SDK build and as suddenly as it appeared, it just went away… I’m not entirely sure what caused this but by switching back to device build and then again to a simulator build it seems to have gone away.

I get the exact same error when building for iOS. This error started after upgrading my existing project to Unity 5.4.2f1 (personal edition). The error appears both when building for Simulator SDK and for Device SDK.

Projects created with the same version (i.e. not upgraded) do not throw this error.

ArgumentOutOfRangeException: Cannot be negative.
Parameter name: length
System.String.Substring (Int32 startIndex, Int32 length) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/String.cs:348)
UnityEditor.iOS.PostProcessiPhonePlayer.PostProcess (BuildTarget target, System.String stagingAreaData, System.String stagingArea, System.String stagingAreaDataManaged, System.String playerPackage, System.String installPath, System.String companyName, System.String productName, BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry) (at /Users/builduser/buildslave/unity/build/PlatformDependent/iPhonePlayer/Extensions/Common/BuildPostProcessor.cs:399)
UnityEditor.iOS.iOSBuildPostprocessor.PostProcess (BuildPostProcessArgs args) (at /Users/builduser/buildslave/unity/build/PlatformDependent/iPhonePlayer/Extensions/Common/ExtensionModule.cs:27)
UnityEditor.PostprocessBuildPlayer.Postprocess (BuildTarget target, System.String installPath, System.String companyName, System.String productName, Int32 width, Int32 height, System.String downloadWebplayerUrl, System.String manualDownloadWebplayerUrl, BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.BuildReporting.BuildReport report) (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/PostprocessBuildPlayer.cs:176)
UnityEditor.HostView:OnGUI()

The Bundle Id has to have a the following format: www.something.somthingelse

If you only use 1 word this error comes up.

Check your app id, if app id doesn’t contains dot i.e. ‘myApp’ then unity will throw above exception. Only work around is use app id which contains at least one dot i.e. ‘com.myApp’