Search Issue Tracker

Won't Fix



Found in








Issue ID




UNITY_IOS is defined and the Post-Processing code using UnityEditor.iOS.Xcode is called only then if iOS is the Active Platform



The UnityEditor.iOS.Xcode namespace contains useful classes to work with XCode projects and to automate certain Build post-processing steps. However, the code is part of the iOS Build Support and needs to be installed separately. It can therefore not be relied upon to exist, otherwise, Users who don't have the iOS Build Support installed will get a compilation Error. This makes it difficult to use UnityEditor.iOS.Xcode in Editor Tools that are intended to be used across a wide variety of Unity projects. One might try to conditionally compile the code with UNITY_IOS but that has a serious downside: UNITY_IOS is only defined when iOS is the active platform. However, it is possible to do an iOS build without iOS being the active platform using the BuildPipeline API. In this case, the post-processing code using UnityEditor.iOS.Xcode will _not_ be called. The user has to remember to switch platforms before doing a build and that might not be possible when the build is automated.

To reproduce:

1. Download attached “" project and open in Unity
2. Make sure that Active Platform is not iOS
3. Press File > Build iOS

Expected Result: After Build completes, console Prints message:

"Running PBXProject post-processing...
XcodeTest:PostProcessBuild(BuildTarget, String) (at Assets/Editor/XcodeTest.cs:19)
UnityEditor.BuildPipeline:BuildPlayer(EditorBuildSettingsScene[], String, BuildTarget, BuildOptions)
XcodeTest:IosBuild() (at Assets/Editor/XcodeTest.cs:13)"

Actual Result: After Build completes, console Prints message:

"Not running post-processing, UNITY_IOS is not defined...
XcodeTest:PostProcessBuild(BuildTarget, String) (at Assets/Editor/XcodeTest.cs:22)
UnityEditor.BuildPipeline:BuildPlayer(EditorBuildSettingsScene[], String, BuildTarget, BuildOptions)
XcodeTest:IosBuild() (at Assets/Editor/XcodeTest.cs:13)"

- I noticed that using BuildPipeline.BuildPlayer this way will change the active platform but not recompile the Editor code. After doing the steps above, iOS is selected as the Active Platform but doing another Build will still _not_ have UNITY_IOS set. Only switching to another Platform and back or making a change that will recompile the Editor Code will set UNITY_IOS
- There are three ways this can be resolved:
1. Unity recompiles the editor code before doing a build to make sure UNITY_IOS is always defined for editor code when doing an iOS build
2. Unity defines scripting define symbol when the iOS Build Support is installed
3. The UnityEditor.iOS.Xcode DLL is bundled with the base Unity installation so that it is always available

Reproduced on Unity 2017.4.0f1, 2017.4.29f1, 2018.3.14f1, 2018.4.2f1, 2019.1.7f1, 2019.2.0b6 and 2019.3.0a6

  1. Response avatar

    Resolution Note:

    The UnityEditor.iOS.Xcode libraries are currently only bundled with the iOS Support installer. Were are considering moving it into an independent package at some point in the future

    The source of the Xcode Manipulation API is available here, it should be possible to use it without needing to download the rest of iOS support.

Comments (1)

  1. 5658a61b5b2955e6ea1e58db1cf3fb50?d=mm


    Oct 15, 2019 01:16

    This problem is very annoying for asset developers that want to include custom build steps for iOS. There are only bad solutions:
    * Using the Xcode namespace breaks for users that do not have the ios build pipeline installed
    * using UNITY_IOS also breaks for some users e.g. that use unity command line builds and other scripted builds
    * using the source code can also conflict with the user end

    Just having a UNITY_IOS_AVAILABLE define would be a great help

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.