背景:
我相信我正在按照本文的建议进行操作:从Unity到iOS,如何完美地自动化框架,设置和plist?
我已经确认调用了PostBuildProcess函数,并更改了info.plist。我记录了输出,它看起来正确。我还在代码(info2.plist)中保存了第二个文件,它包含了我期望的所有更改。但是,原始文件(info.plist)被不同的值覆盖。
在PostProcessBuild函数运行之后,似乎Unity覆盖了info.plist文件。
代码位于Unity项目的/ Assets / Editor文件夹中。
这是我的功能之一:
[PostProcessBuild(1)]
public static void ChangeXcodePlist(BuildTarget buildTarget, string pathToBuiltProject)
{
if (buildTarget == BuildTarget.iOS)
{
// Get plist file and read it.
string plistPath = pathToBuiltProject + "/Info.plist";
Debug.Log("In the ChangeXCodePlist, path is: " + plistPath);
PlistDocument plist = new PlistDocument();
plist.ReadFromString(File.ReadAllText(plistPath));
Debug.Log("In the ChangeXCodePlist");
// Get root
PlistElementDict rootDict = plist.root;
// Required when using camera for demos, e.g. AR demos.
rootDict.SetString("NSCameraUsageDescription", "Uses …Run Code Online (Sandbox Code Playgroud)