Guest User

Untitled

a guest
Feb 12th, 2023
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.89 KB | Gaming | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3. using UnityEditor.Callbacks;
  4. using UnityEditor;
  5. using System;
  6. using UnityEditor.iOS.Xcode;
  7. using System.IO;
  8.  
  9. // 9:03 PM 9/7/2017
  10. // from: https://stackoverflow.com/questions/35739361/itsappusesnonexemptencryption-export-compliance-while-internal-testing
  11.  
  12. public class IOSBuildTools : MonoBehaviour
  13. {
  14.     [PostProcessBuild]
  15.     public static void ChangeXcodePlist(BuildTarget buildTarget, string pathToBuiltProject)
  16.     {
  17.         if (buildTarget == BuildTarget.iOS)
  18.         {
  19.             // Get plist
  20.             string plistPath = pathToBuiltProject + "/Info.plist";
  21.             var plist = new PlistDocument();
  22.             plist.ReadFromString(File.ReadAllText(plistPath));
  23.  
  24.             // Get root
  25.             var rootDict = plist.root;
  26.  
  27. //          // Change value of NSCameraUsageDescription in Xcode plist
  28. //          var buildKey = "NSCameraUsageDescription";
  29. //          rootDict.SetString(buildKey, "Taking screenshots");
  30.  
  31.             var rootValues = rootDict.values;
  32.             rootValues.Remove("UIApplicationExitsOnSuspend");
  33.  
  34.             var buildKey2 = "ITSAppUsesNonExemptEncryption";
  35.             rootDict.SetString(buildKey2, "false");
  36.  
  37.             var buildKey3 = "NSLocationWhenInUseUsageDescription";
  38.             rootDict.SetString(buildKey3, "This is not required.");
  39.  
  40.             // Write to file
  41.             File.WriteAllText(plistPath, plist.WriteToString());
  42.         }
  43.  
  44.         if(buildTarget == BuildTarget.iOS)
  45.         {
  46.             string projectPath = pathToBuiltProject + "/Unity-iPhone.xcodeproj/project.pbxproj";
  47.  
  48.             PBXProject pbxProject = new PBXProject();
  49.             pbxProject.ReadFromFile(projectPath);
  50.  
  51.             System.Action<string> RemoveBitcode = (tgt) =>
  52.             {
  53.                 pbxProject.SetBuildProperty(tgt, "ENABLE_BITCODE", "NO");
  54.             };
  55.  
  56. #if UNITY_2020_1_OR_NEWER
  57.             RemoveBitcode(pbxProject.GetUnityMainTargetGuid());
  58.             RemoveBitcode(pbxProject.GetUnityFrameworkTargetGuid());
  59. #else
  60.             RemoveBitcode( pbxProject.TargetGuidByName("Unity-iPhone"));
  61. #endif
  62.  
  63.             pbxProject.WriteToFile (projectPath);
  64.         }
  65.     }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment