FileNotFoundException when using Xcode API

We are using the Xcode API to add frameworks, permissions, and update build settings. Currently we use the XcodeAPI code found here, copied into our project:
https://bitbucket.org/Unity-Technologies/xcodeapi

However, seeing as there is a version included in Unity, documented here:

However, I am getting odd build errors when trying to use types in UnityEditor.iOS.Xcode. Here is a minimal sample that reproduces the bugs:

using UnityEngine;
using System.Collections;
using System.IO;

#if UNITY_EDITOR

using UnityEditor;
using UnityEditor.Callbacks;
using UnityEditor.iOS.Xcode;

public class Editor : MonoBehaviour {
	// A variable from UnityEditor.iOS.Xcode declared in local scope is fine
	public static void LocalScopePlist()
	{
		PlistDocument plist = new PlistDocument();
	}

	// A variable from UnityEditor.iOS.Xcode passed in a function causes an FileNotFoundException
	public static void PassMeAPlist(PlistDocument passedPlist)
	{

	}
}

#endif

Errors I get in the Unity Editor are:

FileNotFoundException: Could not load file or assembly 'UnityEditor.iOS.Extensions.Xcode, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.

FileNotFoundException: Could not load file or assembly 'UnityEditor.iOS.Extensions.Xcode, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.

System.Reflection.MonoMethodInfo.GetMethodInfo (IntPtr handle) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:59)
System.Reflection.MonoMethod.GetPseudoCustomAttributes () (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:293)
System.MonoCustomAttrs.GetPseudoCustomAttributes (ICustomAttributeProvider obj, System.Type attributeType) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System/MonoCustomAttrs.cs:78)
System.MonoCustomAttrs.IsDefined (ICustomAttributeProvider obj, System.Type attributeType, Boolean inherit) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System/MonoCustomAttrs.cs:301)
System.Reflection.MonoMethod.IsDefined (System.Type attributeType, Boolean inherit) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:274)
System.Attribute.IsDefined (System.Reflection.MemberInfo element, System.Type attributeType, Boolean inherit) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System/Attribute.cs:326)
System.Attribute.IsDefined (System.Reflection.MemberInfo element, System.Type attributeType) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System/Attribute.cs:299)
UnityEditor.EditorAssemblies.ProcessStaticMethodAttributes (System.Type type) (at /Users/builduser/buildslave/unity/build/Editor/Mono/EditorAssemblies.cs:95)
UnityEditor.EditorAssemblies.ProcessInitializeOnLoadAttributes () (at /Users/builduser/buildslave/unity/build/Editor/Mono/EditorAssemblies.cs:130)
UnityEditor.EditorAssemblies.SetLoadedEditorAssemblies (System.Reflection.Assembly assemblies) (at /Users/builduser/buildslave/unity/build/Editor/Mono/EditorAssemblies.cs:63)

I have confirmed the dll is present at

/Applications/Unity/Unity.app/Contents/PlaybackEngines/iossupport/UnityEditor.iOS.Extensions.Xcode.dll`

Suggestions?

We just ran in this problem today too. It works for us if we use all UnityEditor.iOS.Xcode related stuff in just one method. The error messages pop up when I move some code in other methods (e.g. a seperate method for setting the build properties).

It works, but I don’t know why. Can someone confirm that?

A way to fix just change playeSetting APi CompatibilityLevel to Net2.0 ,then fine.