From 480b3b1f7049cf867569e9aca0dfff296b50dbf7 Mon Sep 17 00:00:00 2001 From: bitsandfoxes Date: Tue, 26 Nov 2024 17:28:57 +0100 Subject: [PATCH 1/9] added post process to remove deprecated optoin --- src/Sentry.Unity.Editor.iOS/SentryXcodeProject.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Sentry.Unity.Editor.iOS/SentryXcodeProject.cs b/src/Sentry.Unity.Editor.iOS/SentryXcodeProject.cs index 4769e2cb8..0b9121e23 100644 --- a/src/Sentry.Unity.Editor.iOS/SentryXcodeProject.cs +++ b/src/Sentry.Unity.Editor.iOS/SentryXcodeProject.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.IO; using System.Linq; using System.Reflection; @@ -132,7 +133,7 @@ private void AddBuildProperties() _pbxProjectType.GetMethod("AddBuildProperty", new[] { typeof(string), typeof(string), typeof(string) }) .Invoke(_project, new object[] { _mainTargetGuid, "OTHER_LDFLAGS", "-ObjC" }); } - + public void AddSentryNativeBridge() { _logger?.LogInfo("Adding the Sentry Native Bridge."); From 76d3c63e2390cb4cfbd29402fbb2b1e0a0ce222d Mon Sep 17 00:00:00 2001 From: bitsandfoxes Date: Tue, 26 Nov 2024 17:34:42 +0100 Subject: [PATCH 2/9] ? --- .../Scripts/Editor/XcodeProjectUpdater.cs | 40 +++++++++++++++++++ .../Editor/XcodeProjectUpdater.cs.meta | 11 +++++ 2 files changed, 51 insertions(+) create mode 100644 samples/unity-of-bugs/Assets/Scripts/Editor/XcodeProjectUpdater.cs create mode 100644 samples/unity-of-bugs/Assets/Scripts/Editor/XcodeProjectUpdater.cs.meta diff --git a/samples/unity-of-bugs/Assets/Scripts/Editor/XcodeProjectUpdater.cs b/samples/unity-of-bugs/Assets/Scripts/Editor/XcodeProjectUpdater.cs new file mode 100644 index 000000000..0f19026e9 --- /dev/null +++ b/samples/unity-of-bugs/Assets/Scripts/Editor/XcodeProjectUpdater.cs @@ -0,0 +1,40 @@ +using UnityEditor; +using UnityEditor.Callbacks; +using UnityEditor.iOS.Xcode; +using UnityEngine; + +namespace Editor +{ + /// + /// Unity adds the '-mno-thumb' compiler flag by default to iOS builds, but this flag is outdated + /// and no longer supported by modern versions of Xcode. Leaving this flag in the project will cause + /// Xcode builds to fail with an "unsupported option '-mno-thumb' for target" error. This post-process + /// build step removes the flag to ensure the sample works on all versions of Unity. + /// + public static class XcodeProjectUpdater + { + [PostProcessBuild] + public static void OnPostProcessBuild(BuildTarget target, string pathToBuildProject) + { + if (target != BuildTarget.iOS) + { + return; + } + + Debug.Log("XcodeUpdater.OnPostProcessBuild started."); + + var pbxProjectPath = PBXProject.GetPBXProjectPath(pathToBuildProject); + var project = new PBXProject(); + project.ReadFromFile(pbxProjectPath); + + var targetGuid = project.GetUnityMainTargetGuid(); + + Debug.Log("Removing '-mno-thumb' from 'OTHER_CFLAGS'."); + project.UpdateBuildProperty(targetGuid, "OTHER_CFLAGS", null, new[] { "-mno-thumb" }); + + project.WriteToFile(pbxProjectPath); + + Debug.Log("XcodeUpdater.OnPostProcessBuild finished."); + } + } +} diff --git a/samples/unity-of-bugs/Assets/Scripts/Editor/XcodeProjectUpdater.cs.meta b/samples/unity-of-bugs/Assets/Scripts/Editor/XcodeProjectUpdater.cs.meta new file mode 100644 index 000000000..693166430 --- /dev/null +++ b/samples/unity-of-bugs/Assets/Scripts/Editor/XcodeProjectUpdater.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b7813384669334de4b56cc22b1e3384e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: From 38172474cc61f168a76b600b17257c8c95b6eaad Mon Sep 17 00:00:00 2001 From: bitsandfoxes Date: Tue, 26 Nov 2024 17:35:48 +0100 Subject: [PATCH 3/9] rev --- src/Sentry.Unity.Editor.iOS/SentryXcodeProject.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Sentry.Unity.Editor.iOS/SentryXcodeProject.cs b/src/Sentry.Unity.Editor.iOS/SentryXcodeProject.cs index 0b9121e23..c335726a7 100644 --- a/src/Sentry.Unity.Editor.iOS/SentryXcodeProject.cs +++ b/src/Sentry.Unity.Editor.iOS/SentryXcodeProject.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.IO; using System.Linq; using System.Reflection; From 7d1af1a7e8004fe11ed67c35e02068dfea06930a Mon Sep 17 00:00:00 2001 From: bitsandfoxes Date: Wed, 27 Nov 2024 11:06:12 +0100 Subject: [PATCH 4/9] only on 2020 and older and only for iOS --- .../unity-of-bugs/Assets/Scripts/Editor/XcodeProjectUpdater.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/samples/unity-of-bugs/Assets/Scripts/Editor/XcodeProjectUpdater.cs b/samples/unity-of-bugs/Assets/Scripts/Editor/XcodeProjectUpdater.cs index 0f19026e9..290e5522f 100644 --- a/samples/unity-of-bugs/Assets/Scripts/Editor/XcodeProjectUpdater.cs +++ b/samples/unity-of-bugs/Assets/Scripts/Editor/XcodeProjectUpdater.cs @@ -1,3 +1,4 @@ +#if UNITY_IOS && !UNITY_2021_1_OR_NEWER using UnityEditor; using UnityEditor.Callbacks; using UnityEditor.iOS.Xcode; @@ -38,3 +39,4 @@ public static void OnPostProcessBuild(BuildTarget target, string pathToBuildProj } } } +#endif From fdd1f29457c51aaabcaef68f203a40ea647f13f6 Mon Sep 17 00:00:00 2001 From: Sentry Github Bot Date: Wed, 27 Nov 2024 10:08:19 +0000 Subject: [PATCH 5/9] Format code --- src/Sentry.Unity.Editor.iOS/SentryXcodeProject.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Sentry.Unity.Editor.iOS/SentryXcodeProject.cs b/src/Sentry.Unity.Editor.iOS/SentryXcodeProject.cs index c335726a7..4769e2cb8 100644 --- a/src/Sentry.Unity.Editor.iOS/SentryXcodeProject.cs +++ b/src/Sentry.Unity.Editor.iOS/SentryXcodeProject.cs @@ -132,7 +132,7 @@ private void AddBuildProperties() _pbxProjectType.GetMethod("AddBuildProperty", new[] { typeof(string), typeof(string), typeof(string) }) .Invoke(_project, new object[] { _mainTargetGuid, "OTHER_LDFLAGS", "-ObjC" }); } - + public void AddSentryNativeBridge() { _logger?.LogInfo("Adding the Sentry Native Bridge."); From 968bb617ecf8fd65ffda4e852184cf9e49c06e54 Mon Sep 17 00:00:00 2001 From: bitsandfoxes Date: Wed, 27 Nov 2024 14:30:01 +0100 Subject: [PATCH 6/9] exclude editor scripts for samples --- scripts/pack.ps1 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/pack.ps1 b/scripts/pack.ps1 index 7bf828043..81e0dd2d8 100644 --- a/scripts/pack.ps1 +++ b/scripts/pack.ps1 @@ -6,6 +6,8 @@ $exclude = @( "package.json", "Tests", "Tests.meta", + "Editor", + "Editor.meta", "*.asmdef", "*.asmdef.meta", "SentryOptions.json*", From 71952560d198faf8c0f5135b8ed25ef26a51d542 Mon Sep 17 00:00:00 2001 From: bitsandfoxes Date: Wed, 27 Nov 2024 14:41:31 +0100 Subject: [PATCH 7/9] wrong editor --- scripts/pack.ps1 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/pack.ps1 b/scripts/pack.ps1 index 81e0dd2d8..b62772d20 100644 --- a/scripts/pack.ps1 +++ b/scripts/pack.ps1 @@ -6,8 +6,7 @@ $exclude = @( "package.json", "Tests", "Tests.meta", - "Editor", - "Editor.meta", + "XcodeProjectUpdater*", "*.asmdef", "*.asmdef.meta", "SentryOptions.json*", From c38b8f6b39a58da680157f67a4727f8c007f1bec Mon Sep 17 00:00:00 2001 From: bitsandfoxes Date: Wed, 27 Nov 2024 19:18:00 +0100 Subject: [PATCH 8/9] moved fixer from scripts to editor --- .../Assets/{Scripts => }/Editor/XcodeProjectUpdater.cs | 0 .../Assets/{Scripts => }/Editor/XcodeProjectUpdater.cs.meta | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename samples/unity-of-bugs/Assets/{Scripts => }/Editor/XcodeProjectUpdater.cs (100%) rename samples/unity-of-bugs/Assets/{Scripts => }/Editor/XcodeProjectUpdater.cs.meta (100%) diff --git a/samples/unity-of-bugs/Assets/Scripts/Editor/XcodeProjectUpdater.cs b/samples/unity-of-bugs/Assets/Editor/XcodeProjectUpdater.cs similarity index 100% rename from samples/unity-of-bugs/Assets/Scripts/Editor/XcodeProjectUpdater.cs rename to samples/unity-of-bugs/Assets/Editor/XcodeProjectUpdater.cs diff --git a/samples/unity-of-bugs/Assets/Scripts/Editor/XcodeProjectUpdater.cs.meta b/samples/unity-of-bugs/Assets/Editor/XcodeProjectUpdater.cs.meta similarity index 100% rename from samples/unity-of-bugs/Assets/Scripts/Editor/XcodeProjectUpdater.cs.meta rename to samples/unity-of-bugs/Assets/Editor/XcodeProjectUpdater.cs.meta From ff87e9690102f67a916af0917437272bfc9fcfc1 Mon Sep 17 00:00:00 2001 From: bitsandfoxes Date: Wed, 27 Nov 2024 19:18:45 +0100 Subject: [PATCH 9/9] updated 'pack' --- scripts/pack.ps1 | 2 -- 1 file changed, 2 deletions(-) diff --git a/scripts/pack.ps1 b/scripts/pack.ps1 index b62772d20..640f536d5 100644 --- a/scripts/pack.ps1 +++ b/scripts/pack.ps1 @@ -6,7 +6,6 @@ $exclude = @( "package.json", "Tests", "Tests.meta", - "XcodeProjectUpdater*", "*.asmdef", "*.asmdef.meta", "SentryOptions.json*", @@ -24,7 +23,6 @@ Copy-Item "LICENSE.md" -Destination "package-release/LICENSE.md" # Copy samples Copy-Item "samples/unity-of-bugs/Assets/Scenes*" -Destination "package-release/Samples~/unity-of-bugs/" -Recurse -Copy-Item "samples/unity-of-bugs/Assets/Editor*" -Destination "package-release/Samples~/unity-of-bugs/" -Recurse Copy-Item "samples/unity-of-bugs/Assets/Scripts*" -Destination "package-release/Samples~/unity-of-bugs/" -Recurse # Create zip