Skip to content

Instantly share code, notes, and snippets.

@osmanzeki
Forked from TiborUdvari/ExcemptFromEncryption.cs
Created December 21, 2020 18:44
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 osmanzeki/116c79e83b4fbf3c17c1b8769779b7b8 to your computer and use it in GitHub Desktop.
Save osmanzeki/116c79e83b4fbf3c17c1b8769779b7b8 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