DisableBitcode.cs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /**
  2. * Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
  3. *
  4. * You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
  5. * copy, modify, and distribute this software in source code or binary form for use
  6. * in connection with the web services and APIs provided by Facebook.
  7. *
  8. * As with any software that integrates with the Facebook platform, your use of
  9. * this software is subject to the Facebook Developer Principles and Policies
  10. * [http://developers.facebook.com/policy/]. This copyright notice shall be
  11. * included in all copies or substantial portions of the software.
  12. *
  13. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  15. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  16. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  17. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  18. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  19. */
  20. using System.IO;
  21. using UnityEngine;
  22. using UnityEditor;
  23. #if UNITY_IOS
  24. using UnityEditor.Build.Reporting;
  25. using UnityEditor.iOS.Xcode;
  26. #endif
  27. using UnityEditor.Callbacks;
  28. namespace Facebook.Unity.PostProcess
  29. {
  30.     /// <summary>
  31.     /// Automatically disables Bitcode on iOS builds
  32.     /// </summary>
  33. public static class DisableBitcode
  34. {
  35. [PostProcessBuildAttribute(999)]
  36. public static void OnPostProcessBuild(BuildTarget buildTarget, string pathToBuildProject)
  37. {
  38. #if UNITY_IOS
  39. if (buildTarget != BuildTarget.iOS) return;
  40. string projectPath = pathToBuildProject + "/Unity-iPhone.xcodeproj/project.pbxproj";
  41. PBXProject pbxProject = new PBXProject();
  42. pbxProject.ReadFromFile(projectPath);
  43. //Disabling Bitcode on all targets
  44. //Main
  45. string target = pbxProject.GetUnityMainTargetGuid();
  46. pbxProject.SetBuildProperty(target, "ENABLE_BITCODE", "NO");
  47. //Unity Tests
  48. target = pbxProject.TargetGuidByName(PBXProject.GetUnityTestTargetName());
  49. pbxProject.SetBuildProperty(target, "ENABLE_BITCODE", "NO");
  50. //Unity Framework
  51. target = pbxProject.GetUnityFrameworkTargetGuid();
  52. pbxProject.SetBuildProperty(target, "ENABLE_BITCODE", "NO");
  53. pbxProject.WriteToFile(projectPath);
  54. #endif
  55. }
  56. }
  57. }