SetEnableBitcode and SetAppUsesNonExemptEncryption
They do their job. But EnableAllAppIconAssets doesn’t work.
namespace Build.Editor
{
using System.IO;
using UnityEditor;
using UnityEditor.Build;
using UnityEditor.Build.Reporting;
using UnityEditor.iOS.Xcode;
public class SetDefaultValuesForIosProject : IPostprocessBuildWithReport
{
public int callbackOrder => 0;
public void OnPostprocessBuild(BuildReport report)
{
if (report.summary.platform == BuildTarget.iOS)
{
ModifyXcodeProject(report.summary.outputPath);
}
}
private static void ModifyXcodeProject(string pathToBuildProject)
{
SetEnableBitcode(pathToBuildProject, false);
SetAppUsesNonExemptEncryption(pathToBuildProject, false);
EnableAllAppIconAssets(pathToBuildProject);
}
private static void SetEnableBitcode(string pathToBuildProject, bool value)
{
var project = new PBXProject();
var projectPath = PBXProject.GetPBXProjectPath(pathToBuildProject);
project.ReadFromFile(projectPath);
var unityFrameworkTarget = project.GetUnityFrameworkTargetGuid();
project.SetBuildProperty(unityFrameworkTarget, “ENABLE_BITCODE”, value ? “YES” : “NO”);
project.WriteToFile(projectPath);
}
private static void SetAppUsesNonExemptEncryption(string pathToBuildProject, bool value)
{
var plistPath = Path.Combine(pathToBuildProject, “Info.plist”);
var plist = new PlistDocument();
plist.ReadFromFile(plistPath);
var rootDict = plist.root;
rootDict.SetBoolean(“ITSAppUsesNonExemptEncryption”, value);
plist.WriteToFile(plistPath);
}
private static void EnableAllAppIconAssets(string xcodeProjectPath)
{
var project = new PBXProject();
var projectPath = PBXProject.GetPBXProjectPath(xcodeProjectPath);
project.ReadFromFile(projectPath);
var unityFrameworkTarget = project.GetUnityFrameworkTargetGuid();
project.SetBuildProperty(unityFrameworkTarget, “INCLUDE_ALL_APP_ICON_ASSET”, “YES”);
project.WriteToFile(xcodeProjectPath);
}
}
}