Last active
December 12, 2023 20:58
-
-
Save SiarheiPilat/17e900363502aacf743265f19af79e0c to your computer and use it in GitHub Desktop.
Automates encryption compliance setting for iOS builds.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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