PlistSSLExtend.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using System.IO;
  2. using Prime31.Xcode;
  3. using UnityEditor;
  4. using UnityEditor.Callbacks;
  5. using UnityEngine;
  6. public class ChangeIOSBuildNumber
  7. {
  8. [PostProcessBuild(999)]
  9. public static void ChangeXcodePlist(BuildTarget buildTarget, string pathToBuiltProject)
  10. {
  11. if (buildTarget == BuildTarget.iOS)
  12. {
  13. Debug.Log("Write NSAppTransportSecurity settings to Info.plist ....");
  14. // Get plist
  15. string plistPath = pathToBuiltProject + "/Info.plist";
  16. PlistDocument plist = new PlistDocument();
  17. plist.ReadFromString(File.ReadAllText(plistPath));
  18. // Get root
  19. PlistElementDict rootDict = plist.root;
  20. var nsApp = rootDict.CreateDict("NSAppTransportSecurity");
  21. var nsEx = nsApp.CreateDict("NSExceptionDomains");
  22. var facebook = nsEx.CreateDict("facebook.com");
  23. facebook.SetBoolean("NSIncludesSubdomains",true);
  24. facebook.SetBoolean("NSExceptionRequiresForwardSecrecy", false);
  25. var fbcdn = nsEx.CreateDict("fbcdn.net");
  26. fbcdn.SetBoolean("NSIncludesSubdomains", true);
  27. fbcdn.SetBoolean("NSExceptionRequiresForwardSecrecy", false);
  28. var akamaihd = nsEx.CreateDict("akamaihd.net");
  29. akamaihd.SetBoolean("NSIncludesSubdomains", true);
  30. akamaihd.SetBoolean("NSExceptionRequiresForwardSecrecy", false);
  31. var gamatic = nsEx.CreateDict("gamatic.com");
  32. gamatic.SetBoolean("NSIncludesSubdomains", true);
  33. gamatic.SetBoolean("NSExceptionRequiresForwardSecrecy", false);
  34. var flurry = nsEx.CreateDict("flurry.com");
  35. flurry.SetBoolean("NSIncludesSubdomains", true);
  36. flurry.SetBoolean("NSExceptionRequiresForwardSecrecy", false);
  37. //Save
  38. File.WriteAllText(plistPath, plist.WriteToString());
  39. Debug.Log("Write NSAppTransportSecurity settings to Info.plist .... done!");
  40. }
  41. }
  42. }