效果和手動新增相同

在Assets\Editor下隨便建立一個cs檔案:

public class IosBuildScript : UnityEngine.MonoBehaviour {
	[UnityEditor.Callbacks.PostProcessBuild(999)]
	public  static  void OnPostprocessBuild (UnityEditor.BuildTarget BuildTarget, string path){
		if (BuildTarget == UnityEditor.BuildTarget.iOS) {
			UnityEngine.Debug.Log (path);

			//新增系統framework
			{
				string projPath = UnityEditor.iOS.Xcode.PBXProject.GetPBXProjectPath (path);
				UnityEditor.iOS.Xcode.PBXProject proj = new UnityEditor.iOS.Xcode.PBXProject ();

				proj.ReadFromString (System.IO.File.ReadAllText (projPath));
				string target = proj.TargetGuidByName (UnityEditor.iOS.Xcode.PBXProject.GetUnityTargetName ());
				// システムのフレームワークを追加
				proj.AddFrameworkToProject (target, "CoreTelephony.framework", false);
				proj.AddFrameworkToProject (target, "libstdc++.6.0.9.tbd", false);
				// 書き出し
				System.IO.File.WriteAllText (projPath, proj.WriteToString ());
			}
			//Handle info.plist
			{
				string plistPath = path + "/Info.plist";
				UnityEditor.iOS.Xcode.PlistDocument plist = new UnityEditor.iOS.Xcode.PlistDocument ();
				plist.ReadFromString (System.IO.File.ReadAllText (plistPath));
				UnityEditor.iOS.Xcode.PlistElementDict rootDict = plist.root;

				rootDict.SetString ("NSMicrophoneUsageDescription", "測試騰訊雲遊戲語音錄音");
				System.IO.File.WriteAllText (plistPath, plist.WriteToString ());
			}
		}
	}
}