-
-
Notifications
You must be signed in to change notification settings - Fork 55
fix: Append
builds for iOS respect CLI option changes
#2146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
if (cliOptions != null && cliOptions.IsValid(logger, EditorUserBuildSettings.development)) | ||
{ | ||
logger.LogInfo("Automatic symbol upload enabled. Adding script to build phase."); | ||
|
||
SentryCli.CreateSentryProperties(pathToProject, cliOptions, options); | ||
SentryCli.SetupSentryCli(pathToProject, RuntimePlatform.OSXEditor); | ||
sentryXcodeProject.AddBuildPhaseSymbolUpload(cliOptions); | ||
} | ||
else if (options.Il2CppLineNumberSupportEnabled) | ||
{ | ||
logger.LogWarning("The IL2CPP line number support requires the debug symbol upload to be enabled."); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved this out of SetupSentry
into SetupSentryCli
.
SetupSentry
is responsible for adding the framework and modifying the Xcode project to have the options and bridge set.
SetupSentryCli
adds the executable, writes the .properties
and adds the script to invoke the symbol upload.
if (options.Il2CppLineNumberSupportEnabled && cliOptions.IsValid(logger, EditorUserBuildSettings.development)) | ||
{ | ||
logger.LogWarning("The IL2CPP line number support requires the debug symbol upload to be enabled."); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We want to log configuration that is allowed but that we already know might not yield the expected result. I.e. the user has LineNumberSupport
enabled but skips the symbol upload.
_pbxProjectType.GetMethod("SetBuildProperty", new[] { typeof(string), typeof(string), typeof(string) }) | ||
.Invoke(_project, new object[] { _mainTargetGuid, IncludeSourcesPropertyName, sentryCliOptions.UploadSources ? "YES" : "NO" }); | ||
|
||
_pbxProjectType.GetMethod("SetBuildProperty", new[] { typeof(string), typeof(string), typeof(string) }) | ||
.Invoke(_project, new object[] { _mainTargetGuid, AllowFailurePropertyName, sentryCliOptions.IgnoreCliErrors ? "YES" : "NO" }); | ||
|
||
if (sentryCliOptions.IgnoreCliErrors) | ||
_pbxProjectType.GetMethod("SetBuildProperty", new[] { typeof(string), typeof(string), typeof(string) }) | ||
.Invoke(_project, new object[] { _mainTargetGuid, PrintLogsPropertyName, sentryCliOptions.IgnoreCliErrors ? "NO" : "YES" }); | ||
|
||
if (MainTargetContainsSymbolUploadBuildPhase()) | ||
{ | ||
uploadDifArguments += " --allow-failure"; | ||
_logger?.LogInfo("Success. Build phase '{0}' was already added.", SymbolUploadPhaseName); | ||
return; | ||
} | ||
|
||
var uploadScript = string.Format(_uploadScript, | ||
SentryCli.SentryCliMacOS, | ||
uploadDifArguments, | ||
// Xcode parses the log-messages for 'error:', causing the phase to error with | ||
// 'Command PhaseScriptExecution emitted errors but did not return a nonzero exit code to indicate failure' | ||
// even with the '--allow-failure' arg. In that case, we're just logging to file instead. | ||
sentryCliOptions.IgnoreCliErrors ? LogOnlyArg : LogAndPrintArg); | ||
_logger?.LogDebug("Adding the upload script to {0}.", SymbolUploadPhaseName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These properties can get overwritten via Unity's PBXProject. The shellscript itself cannot. Attempting to overwrite the script causes unexpected behaviour like adding it twice.
Instead, the properties get set (and overwritten) during the Unity export and read by the script during the Xcode build
Co-authored-by: Ivan Dlugos <6349682+vaind@users.noreply.github.com>
Fixes #1973
There are a couple of limitations with the PBXProject API, namely the ability to remove or overwrite an existing shell script in the build phase. When building via
append
this caused CLI options to not get copied over and respected by Xcode.Instead of hardcoding arguments the shell script is now controlled by build settings that can be modified when building.