Keine Beschreibung
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

XCodeSwiftSupportPostProcess.cs 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #if !UNITY_2020_1_OR_NEWER && UNITY_IOS
  2. using UnityEngine;
  3. using UnityEditor;
  4. using UnityEditor.Callbacks;
  5. using UnityEditor.iOS.Xcode;
  6. public class XCodeSwiftSupportPostProcess
  7. {
  8. [PostProcessBuild]
  9. public static void OnPostprocessBuild(BuildTarget target, string path)
  10. {
  11. string projPath = PBXProject.GetPBXProjectPath(path);
  12. PBXProject proj = new PBXProject();
  13. proj.ReadFromFile(projPath);
  14. string targetGuid = GetTargetGUID(proj);
  15. proj.SetBuildProperty(targetGuid, "ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES", "YES");
  16. if (ShouldAddSwiftVersion())
  17. {
  18. proj.SetBuildProperty(targetGuid, "SWIFT_VERSION", "5.0");
  19. }
  20. proj.WriteToFile(projPath);
  21. }
  22. private static bool ShouldAddSwiftVersion() {
  23. #if UNITY_2019_1_OR_NEWER
  24. return false;
  25. #else
  26. return true;
  27. #endif
  28. }
  29. private static string GetTargetGUID(PBXProject project) {
  30. #if UNITY_2019_3_OR_NEWER
  31. return project.GetUnityFrameworkTargetGuid();
  32. #else
  33. return project.TargetGuidByName(PBXProject.GetUnityTargetName());
  34. #endif
  35. }
  36. }
  37. #endif //UNITY_2018_1_OR_NEWER