由于缺少 plist 键值对,Unity 2020.1.8f1 无法构建 xcode 项目
Unity 2020.1.8f1 cannot build xcode project because of missing plist key value pairs
我们最近更新了一个项目到Unity 2020.1.8f1
但它不会为 iOS 构建 xcode 项目,因为缺少 plist 键值对。
这真的很奇怪,之前,我会构建 xcode 项目,然后修复 plist 的东西,然后构建到 iOS.
以下是我在尝试构建时遇到的错误。
WebCamTexture class is used but Camera Usage Description is empty. App will not work on iOS 10+.
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean &)(at / Users / bokken / buildslave / unity / build / Modules / IMGUI / GUIUtility.cs:189)
Microphone class is used but Microphone Usage Description is empty. App will not work on iOS 10+.
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&) (at /Users/bokken/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:189)
我尝试将此脚本添加到资产中的编辑器文件夹
using UnityEngine;
using UnityEditor;
using UnityEditor.Callbacks;
using System.Collections;
using UnityEditor.iOS.Xcode;
using System.IO;
public class AddStuffToplist {
[PostProcessBuild]
public static void ChangeXcodePlist(BuildTarget buildTarget, string pathToBuiltProject)
{
if (buildTarget == BuildTarget.iOS) {
Debug.Log("adding plist stuff");
// Get plist
string plistPath = pathToBuiltProject + "/Info.plist";
PlistDocument plist = new PlistDocument();
plist.ReadFromString(File.ReadAllText(plistPath));
// Get root
PlistElementDict rootDict = plist.root;
rootDict.SetString("NSCameraUsageDescription","Natcorder unity asset uses this");
rootDict.SetString("NSMicrophoneUsageDescription","Natcorder unity asset uses this");
rootDict.SetString("NSPhotoLibraryUsageDescription","Natcorder unity asset uses this");
//rootDict.SetString("Privacy - Photo Library Usage Description", "Natcorder unity asset uses this");
//rootDict.SetString("Privacy - Microphone Usage Description", "Natcorder unity asset uses this");
// Write to file
File.WriteAllText(plistPath, plist.WriteToString());
}
}
}
如果我使用 Privacy - Microphone Usage Description 或 NSMicrophoneUsageDescription 作为密钥,我会得到完全相同的错误。
此外,我添加的“添加 plist 内容”调试行从未出现在控制台中,所以也许这个脚本不起作用?
好的,我查看了构建设置。我想看看是否可以在构建之前设置自定义 info.plist 文件,例如为 Android..
设置自定义 maintemplate.gradle
我发现了这个...
看起来他们最近随机添加了这个。
感谢团结!
我们最近更新了一个项目到Unity 2020.1.8f1 但它不会为 iOS 构建 xcode 项目,因为缺少 plist 键值对。 这真的很奇怪,之前,我会构建 xcode 项目,然后修复 plist 的东西,然后构建到 iOS.
以下是我在尝试构建时遇到的错误。
WebCamTexture class is used but Camera Usage Description is empty. App will not work on iOS 10+.
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean &)(at / Users / bokken / buildslave / unity / build / Modules / IMGUI / GUIUtility.cs:189)
Microphone class is used but Microphone Usage Description is empty. App will not work on iOS 10+.
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&) (at /Users/bokken/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:189)
我尝试将此脚本添加到资产中的编辑器文件夹
using UnityEngine;
using UnityEditor;
using UnityEditor.Callbacks;
using System.Collections;
using UnityEditor.iOS.Xcode;
using System.IO;
public class AddStuffToplist {
[PostProcessBuild]
public static void ChangeXcodePlist(BuildTarget buildTarget, string pathToBuiltProject)
{
if (buildTarget == BuildTarget.iOS) {
Debug.Log("adding plist stuff");
// Get plist
string plistPath = pathToBuiltProject + "/Info.plist";
PlistDocument plist = new PlistDocument();
plist.ReadFromString(File.ReadAllText(plistPath));
// Get root
PlistElementDict rootDict = plist.root;
rootDict.SetString("NSCameraUsageDescription","Natcorder unity asset uses this");
rootDict.SetString("NSMicrophoneUsageDescription","Natcorder unity asset uses this");
rootDict.SetString("NSPhotoLibraryUsageDescription","Natcorder unity asset uses this");
//rootDict.SetString("Privacy - Photo Library Usage Description", "Natcorder unity asset uses this");
//rootDict.SetString("Privacy - Microphone Usage Description", "Natcorder unity asset uses this");
// Write to file
File.WriteAllText(plistPath, plist.WriteToString());
}
}
}
如果我使用 Privacy - Microphone Usage Description 或 NSMicrophoneUsageDescription 作为密钥,我会得到完全相同的错误。
此外,我添加的“添加 plist 内容”调试行从未出现在控制台中,所以也许这个脚本不起作用?
好的,我查看了构建设置。我想看看是否可以在构建之前设置自定义 info.plist 文件,例如为 Android..
设置自定义 maintemplate.gradle我发现了这个...
看起来他们最近随机添加了这个。 感谢团结!