Skip to content

Instantly share code, notes, and snippets.

@TiborUdvari
Last active April 23, 2024 16:22
Show Gist options
  • Save TiborUdvari/4679d636b17ddff0d83065eefa399c04 to your computer and use it in GitHub Desktop.
Save TiborUdvari/4679d636b17ddff0d83065eefa399c04 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
}
}
}
@matheustaveiros
Copy link

Thankssss, works fine!

@adamlucax
Copy link

NICE JOB!!!

@Won-gyu
Copy link

Won-gyu commented Sep 2, 2022

Thanks!

@squio
Copy link

squio commented Sep 28, 2022

Great work 👍

For anyone wondering how to install this: simple copy the source and save to file in your assets folder:
Assets/Editor/ExcemptFromEncryption.cs

That is all 🎉

@liquidbuddha
Copy link

what if the app uses non-exempt encryption... is there a way to set for the appropriate setting?

Would it be changing the callbackOrder to 1 or 2?

@wfettich
Copy link

wfettich commented Aug 20, 2023

no, you need to put it in {project root}\Editor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment