add new bool item to info.plist with UnityEditor.iOS.Xcode

I used this example:
http://forum.unity3d.com/threads/how-can-you-add-items-to-the-xcode-project-targets-info-plist-using-the-xcodeapi.330574/

To successfully add a new element array to info.plist when building to iOS. Hurrah.

I want to now add a bool element to the info.plist but I can not figure it out. I wish the unity documentation had examples.

Here’s my failed attempt, how can I fix it? I get all kinds of type conversion errors

// WORKING:
			// Get plist 
			string plistPath = pathToBuiltProject + "/Info.plist";
			PlistDocument plist = new PlistDocument();
			plist.ReadFromString(File.ReadAllText(plistPath));

			// Get root
			PlistElementDict rootDict = plist.root;

// NOT WORKING:
		
			// add iTunes write to file permissions
			PlistElementBoolean iTunesFileSupport = rootDict.CreateArray("Application supports iTunes file sharing");
			iTunesFileSupport.AsBoolean(true);

It’s literally this:

			// Enable iTunes file sharing

			rootDict.SetBoolean ("UIFileSharingEnabled", true);

In the case of the array of items, like in supported external devices, a new array must be created and new string added. But in this case, all I had to do was use the set boolean function, the key of “Application supports iTunes file sharing” which is “UIFileSharingEnabled” and set it to true.

heres a reference for iOS info.plist keys: iOS Keys

#2019

#full, up-to-date answer

https://stackoverflow.com/a/54370793/294884