private static void SetPlist(PBXProject proj, PlistElementArray node, ArrayList arg) { if (arg != null) { foreach (object i in arg) { object val = i; var vType = i.GetType(); if (vType == typeof(string)) { node.AddString((string)val); } else if (vType == typeof(bool)) { node.AddBoolean((bool)val); } else if (vType == typeof(double)) { int v = int.Parse(val.ToString()); node.AddInteger(v); } else if (vType == typeof(ArrayList)) { var t = node.AddArray(); var array = val as ArrayList; SetPlist(proj, t, array); } else if (vType == typeof(Hashtable)) { var t = node.AddDict(); var table = val as Hashtable; SetPlist(proj, t, table); } } } }
public static void PatchInfoPlist(string pathToBuiltProject) { string plistPath = Path.Combine(pathToBuiltProject, "Info.plist"); PlistDocument plist = new PlistDocument(); plist.ReadFromFile(plistPath); // ================================= // We must do this here instead of passing the plist to // a useful helper function because Unity refuses to build functions // where a variable of type PlistDocument is passed. string key = "UISupportedExternalAccessoryProtocols"; string[] values = new string[3] { "io.structure.control", "io.structure.depth", "io.structure.infrared" }; if (plist.root.values.ContainsKey(key)) return; PlistElementArray array = new PlistElementArray(); foreach (string value in values) array.AddString(value); plist.root.values.Add (new PlistEntry(key, array)); // ================================= plist.root.values.Add( new PlistEntry("UIFileSharingEnabled", new PlistElementBoolean(true) ) ); plist.WriteToFile(plistPath); }