Skip to content

Instantly share code, notes, and snippets.

@SiarheiPilat
Last active December 12, 2023 20:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SiarheiPilat/17e900363502aacf743265f19af79e0c to your computer and use it in GitHub Desktop.
Save SiarheiPilat/17e900363502aacf743265f19af79e0c to your computer and use it in GitHub Desktop.
Automates encryption compliance setting for iOS builds.
#if UNITY_IOS
using UnityEngine;
using UnityEditor.Build;
using UnityEditor.Build.Reporting;
using UnityEditor;
using UnityEditor.iOS.Xcode;
using System.IO;
public class ExcemptFromEncryption : IPostprocessBuildWithReport // Will execute after XCode project is built
{
public int callbackOrder { get { return 0; } }
public void OnPostprocessBuild(BuildReport report)
{
if (report.summary.platform == BuildTarget.iOS) // Check if the build is for iOS
{
string plistPath = report.summary.outputPath + "/Info.plist";
PlistDocument plist = new PlistDocument(); // Read Info.plist file into memory
plist.ReadFromString(File.ReadAllText(plistPath));
PlistElementDict rootDict = plist.root;
rootDict.SetBoolean("ITSAppUsesNonExemptEncryption", false);
File.WriteAllText(plistPath, plist.WriteToString()); // Override Info.plist
}
}
}
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment