iOSPostProcessBuild.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. #if UNITY_IOS
  2. using UnityEngine;
  3. using UnityEditor;
  4. using UnityEditor.Callbacks;
  5. using System.IO;
  6. using UnityEditor.iOS.Xcode;
  7. #endif
  8. public class iOSPostProcessBuild
  9. {
  10. #if UNITY_IOS
  11. #pragma warning disable 0162
  12. [PostProcessBuild]
  13. public static void OnPostprocessBuild(BuildTarget target, string buildPath)
  14. {
  15. if (target == BuildTarget.iOS)
  16. {
  17. string projectPath = PBXProject.GetPBXProjectPath(buildPath);
  18. string plistPath = Path.Combine(buildPath, "Info.plist");
  19. PlistDocument plist = new PlistDocument();
  20. plist.ReadFromString(File.ReadAllText(plistPath));
  21. PlistElementDict rootDict = plist.root;
  22. rootDict.SetBoolean("ITSAppUsesNonExemptEncryption", false);
  23. File.WriteAllText(plistPath, plist.WriteToString());
  24. var pbxProject = new PBXProject();
  25. pbxProject.ReadFromFile(projectPath);
  26. pbxProject.SetBuildProperty(pbxProject.GetUnityFrameworkTargetGuid(), "ENABLE_BITCODE", "NO");
  27. pbxProject.SetBuildProperty(pbxProject.GetUnityMainTargetGuid(), "ENABLE_BITCODE", "NO");
  28. pbxProject.WriteToFile(projectPath);
  29. }
  30. }
  31. #pragma warning restore 0162
  32. #endif
  33. }