Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more..
    Dismiss Notice
  3. Dismiss Notice

get / set iOS BuildSetting "Run in Xcode As" aka. iOSBuildType from script

Discussion in 'Editor & General Support' started by TimHeijden, Nov 6, 2016.

  1. TimHeijden

    TimHeijden

    Joined:
    Mar 5, 2015
    Posts:
    34
    I'm currently writing a custom build pipeline and I'd like it to contain all the options Unity's build settings offers. It's going quite well but I'm having trouble get/setting the iOS variable "iOSBuildType", better known as "Run in Xcode As":



    When I initially looked at EditorUserBuildSettings class, I didn't find any value resembling this option. After looking in other locations and failing, I did some more research.

    Eventually, I found out that EditorUserBuildSettings DOES have a property called "iOSBuildConfigType". I even managed to find "documentation" on it: https://docs.unity3d.com/550/Documentation/ScriptReference/iOSBuildType.html

    Sadly, this property isn't actually public! Is there a reason for this, such as it now being available elsewhere?

    It seems weird because it's pretty much the only value in EditorUserBuildSettings that isn't public. (aside from one other property called "symlinkTrampoline").

    Update:
    I also found that this value is actually in the unity docs set as "public":
    https://docs.unity3d.com/550/Docume...itorUserBuildSettings-iOSBuildConfigType.html

    It looks like this value will be exposed in 5.5! Can someone confirm that? :) (it's not in the beta release notes)
     
    Last edited: Nov 6, 2016
  2. TimHeijden

    TimHeijden

    Joined:
    Mar 5, 2015
    Posts:
    34
    Update 2:

    For now I've simply used reflection to edit this value. Here is the code if anyone else wants to use it:

    Code (CSharp):
    1.     // Debug = 0, Release = 1
    2.     private int GetiOSBuildConfigType()
    3.     {
    4.         PropertyInfo pi = typeof(EditorUserBuildSettings).GetProperty("iOSBuildConfigType", BindingFlags.NonPublic | BindingFlags.Static);
    5.  
    6.         // Static class has no instance, so null's
    7.         int val = (int)pi.GetValue(null, null);
    8.      
    9.         return val;
    10.     }
    11.  
    12.     private void SetiOSBuildConfigType(int newConfigType)
    13.     {
    14.         PropertyInfo pi = typeof(EditorUserBuildSettings).GetProperty("iOSBuildConfigType", BindingFlags.NonPublic | BindingFlags.Static);
    15.  
    16.         // Static class has no instance, so null's
    17.         pi.SetValue(null, newConfigType, null);
    18.     }
     
    fffMalzbier likes this.
  3. ceast33

    ceast33

    Joined:
    Apr 22, 2020
    Posts:
    9
    thank you!
     
  4. yiersan729

    yiersan729

    Joined:
    Jan 14, 2019
    Posts:
    1
    EditorUserBuildSettings.iOSBuildConfigType = iOSBuildType.Debug;