Skip to content

Instantly share code, notes, and snippets.

@Kibsgaard
Forked from TiborUdvari/ExcemptFromEncryption.cs
Created December 17, 2021 14:24
Show Gist options
  • Save Kibsgaard/2ab8b8917be88123c5541a33fc6ea224 to your computer and use it in GitHub Desktop.
Save Kibsgaard/2ab8b8917be88123c5541a33fc6ea224 to your computer and use it in GitHub Desktop.
Marks ITSAppUsesNonExemptEncryption in Unity generated Info.plist file to false. Doing this no longer requires manually marking the app as not using non-exempt encryption in iTunes Connect for Testflight beta testing.
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
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment