From 3304e4b440838a418deaea24ed8011b7c55930ac Mon Sep 17 00:00:00 2001 From: bitsandfoxes Date: Wed, 4 Nov 2026 09:54:00 +0100 Subject: [PATCH 1/2] Respect UploadDevelopmentSymbols for iOS symbol upload --- CHANGELOG.md | 6 ++++++ .../BuildPostProcess.cs | 1 + .../SentryXcodeProject.cs | 5 +++-- src/Sentry.Unity/SentryCliOptions.cs | 12 ++++++++++- .../SentryXcodeProjectTests.cs | 21 +++++++++++++++++++ 5 files changed, 42 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 252fc315b..27f2b94f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## Unreleased + +### Fixes + +- On iOS, development builds now respect `UploadDevelopmentSymbols` and no longer upload debug symbols unless it is enabled, matching the other platforms. ([#TBD](https://github.com/getsentry/sentry-unity/pull/TBD)) + ## 4.12.0 ### Behavioral Changes diff --git a/src/Sentry.Unity.Editor.iOS/BuildPostProcess.cs b/src/Sentry.Unity.Editor.iOS/BuildPostProcess.cs index 710486308..58f3f31b3 100644 --- a/src/Sentry.Unity.Editor.iOS/BuildPostProcess.cs +++ b/src/Sentry.Unity.Editor.iOS/BuildPostProcess.cs @@ -210,6 +210,7 @@ internal static void SetupSentryCli(SentryUnityOptions options, using var sentryXcodeProject = SentryXcodeProject.Open(pathToProject, logger); // The app that embeds the game builds `UnityFramework`, but not the Unity app target. sentryXcodeProject.AddBuildPhaseSymbolUpload(cliOptions, + isDevelopmentBuild: EditorUserBuildSettings.development, uploadFromUnityFramework: options.IosNativeInitializationType is NativeInitializationType.External); } catch (Exception e) diff --git a/src/Sentry.Unity.Editor.iOS/SentryXcodeProject.cs b/src/Sentry.Unity.Editor.iOS/SentryXcodeProject.cs index f9b060aa3..51cf429e4 100644 --- a/src/Sentry.Unity.Editor.iOS/SentryXcodeProject.cs +++ b/src/Sentry.Unity.Editor.iOS/SentryXcodeProject.cs @@ -188,14 +188,15 @@ internal void SetSearchPathBuildProperty(string path) .Invoke(_project, new object[] { new[] { _mainTargetGuid, _unityFrameworkTargetGuid }, "FRAMEWORK_SEARCH_PATHS", path }); } - public void AddBuildPhaseSymbolUpload(SentryCliOptions sentryCliOptions, bool uploadFromUnityFramework = false) + public void AddBuildPhaseSymbolUpload(SentryCliOptions sentryCliOptions, bool isDevelopmentBuild = false, bool uploadFromUnityFramework = false) { _logger?.LogInfo("Setting up Sentry CLI build properties and upload script."); var targetGuid = uploadFromUnityFramework ? _unityFrameworkTargetGuid : _mainTargetGuid; + var uploadSymbols = sentryCliOptions.IsUploadEnabled(_logger, isDevelopmentBuild); _pbxProjectType.GetMethod("SetBuildProperty", new[] { typeof(string), typeof(string), typeof(string) }) - .Invoke(_project, new object[] { targetGuid, SymbolUploadPropertyName, sentryCliOptions.UploadSymbols ? "YES" : "NO" }); + .Invoke(_project, new object[] { targetGuid, SymbolUploadPropertyName, uploadSymbols ? "YES" : "NO" }); // Set additional upload properties _pbxProjectType.GetMethod("SetBuildProperty", new[] { typeof(string), typeof(string), typeof(string) }) diff --git a/src/Sentry.Unity/SentryCliOptions.cs b/src/Sentry.Unity/SentryCliOptions.cs index 9dad47a84..75a720daf 100644 --- a/src/Sentry.Unity/SentryCliOptions.cs +++ b/src/Sentry.Unity/SentryCliOptions.cs @@ -31,7 +31,7 @@ internal static string GetConfigPath(string? notDefaultConfigName = null) private static void MissingFieldWarning(IDiagnosticLogger? logger, string name) => logger?.LogWarning("{0} missing. Please set it under {1}", name, EditorMenuPath); - public bool IsValid(IDiagnosticLogger? logger, bool isDevelopmentBuild) + internal bool IsUploadEnabled(IDiagnosticLogger? logger, bool isDevelopmentBuild) { if (!UploadSymbols) { @@ -45,6 +45,16 @@ public bool IsValid(IDiagnosticLogger? logger, bool isDevelopmentBuild) return false; } + return true; + } + + public bool IsValid(IDiagnosticLogger? logger, bool isDevelopmentBuild) + { + if (!IsUploadEnabled(logger, isDevelopmentBuild)) + { + return false; + } + var validated = true; if (string.IsNullOrWhiteSpace(Auth)) { diff --git a/test/Sentry.Unity.Editor.iOS.Tests/SentryXcodeProjectTests.cs b/test/Sentry.Unity.Editor.iOS.Tests/SentryXcodeProjectTests.cs index 6903cf79a..1f7a422c6 100644 --- a/test/Sentry.Unity.Editor.iOS.Tests/SentryXcodeProjectTests.cs +++ b/test/Sentry.Unity.Editor.iOS.Tests/SentryXcodeProjectTests.cs @@ -231,6 +231,27 @@ public void AddBuildPhaseSymbolUpload_OptionsDisabled_SetsCorrectBuildProperties StringAssert.Contains($"{SentryXcodeProject.PrintLogsPropertyName} = YES", projectString); } + [Test] + [TestCase(false, false, "YES")] + [TestCase(false, true, "YES")] + [TestCase(true, false, "NO")] + [TestCase(true, true, "YES")] + public void AddBuildPhaseSymbolUpload_DevelopmentBuild_RespectsUploadDevelopmentSymbols( + bool isDevelopmentBuild, bool uploadDevelopmentSymbols, string expectedValue) + { + var xcodeProject = _fixture.GetSut(); + xcodeProject.ReadFromProjectFile(); + + var sentryCliOptions = ScriptableObject.CreateInstance(); + sentryCliOptions.UploadSymbols = true; + sentryCliOptions.UploadDevelopmentSymbols = uploadDevelopmentSymbols; + + xcodeProject.AddBuildPhaseSymbolUpload(sentryCliOptions, isDevelopmentBuild: isDevelopmentBuild); + + StringAssert.Contains($"{SentryXcodeProject.SymbolUploadPropertyName} = {expectedValue}", xcodeProject.ProjectToString()); + Assert.IsTrue(xcodeProject.MainTargetContainsSymbolUploadBuildPhase()); + } + [Test] public void AddBuildPhaseSymbolUpload_UploadScriptContainsPropertyReferences() { From 7a3971631e813f87df70950f6276abbb463e26d6 Mon Sep 17 00:00:00 2001 From: bitsandfoxes Date: Wed, 4 Nov 2026 10:28:35 +0100 Subject: [PATCH 2/2] Add PR link to CHANGELOG --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 27f2b94f1..c8ca4d866 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ ### Fixes -- On iOS, development builds now respect `UploadDevelopmentSymbols` and no longer upload debug symbols unless it is enabled, matching the other platforms. ([#TBD](https://github.com/getsentry/sentry-unity/pull/TBD)) +- On iOS, development builds now respect `UploadDevelopmentSymbols` and no longer upload debug symbols unless it is enabled, matching the other platforms. ([#2928](https://github.com/getsentry/sentry-unity/pull/2928)) ## 4.12.0