Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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. ([#2928](https://github.com/getsentry/sentry-unity/pull/2928))

## 4.12.0

### Behavioral Changes
Expand Down
1 change: 1 addition & 0 deletions src/Sentry.Unity.Editor.iOS/BuildPostProcess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions src/Sentry.Unity.Editor.iOS/SentryXcodeProject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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) })
Expand Down
12 changes: 11 additions & 1 deletion src/Sentry.Unity/SentryCliOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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))
{
Expand Down
21 changes: 21 additions & 0 deletions test/Sentry.Unity.Editor.iOS.Tests/SentryXcodeProjectTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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>();
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()
{
Expand Down
Loading