diff --git a/src/mono/sample/iOS/Makefile b/src/mono/sample/iOS/Makefile index 01ae748bbda1a3..ef24938c6fd304 100644 --- a/src/mono/sample/iOS/Makefile +++ b/src/mono/sample/iOS/Makefile @@ -6,6 +6,7 @@ AOT?=false TARGET?=iossimulator DEPLOY_AND_RUN?=true APP_SANDBOX?=false +STRIP_DEBUG_SYMBOLS?=false # only used when measuring SOD via build-appbundle make target #If DIAGNOSTIC_PORTS is enabled, RUNTIME_COMPONENTS must also be enabled. #If RUNTIME_COMPONENTS is enabled, DIAGNOSTIC_PORTS is optional. @@ -51,6 +52,7 @@ run-sim: clean appbuilder build-appbundle: clean appbuilder $(DOTNET) publish -c $(MONO_CONFIG) /p:TargetOS=$(TARGET) /p:TargetArchitecture=$(MONO_ARCH) \ '/p:DeployAndRun="$(DEPLOY_AND_RUN)"' \ + /p:StripDebugSymbols=$(STRIP_DEBUG_SYMBOLS) \ /p:UseLLVM=$(USE_LLVM) /p:ForceAOT=$(AOT) /bl \ run-catalyst: diff --git a/src/mono/sample/iOS/Program.csproj b/src/mono/sample/iOS/Program.csproj index 765658d4837d86..00f7e447f04099 100644 --- a/src/mono/sample/iOS/Program.csproj +++ b/src/mono/sample/iOS/Program.csproj @@ -9,6 +9,7 @@ $(TargetOS)-$(TargetArchitecture) $(DefineConstants);CI_TEST HelloiOS + false @@ -92,6 +93,7 @@ RuntimeComponents="$(RuntimeComponents)" EnableAppSandbox="$(EnableAppSandbox)" DiagnosticPorts="$(DiagnosticPorts)" + StripSymbolTable="$(StripDebugSymbols)" AppDir="$(MSBuildThisFileDirectory)$(PublishDir)"> diff --git a/src/tasks/AppleAppBuilder/AppleAppBuilder.cs b/src/tasks/AppleAppBuilder/AppleAppBuilder.cs index 193e047efc68a9..c375de7f1db4ab 100644 --- a/src/tasks/AppleAppBuilder/AppleAppBuilder.cs +++ b/src/tasks/AppleAppBuilder/AppleAppBuilder.cs @@ -163,6 +163,10 @@ public string TargetOS /// public bool EnableAppSandbox { get; set; } + /// Strip local symbols and debug information, and extract it in XcodeProjectPath directory + /// + public bool StripSymbolTable { get; set; } + public override bool Execute() { bool isDevice = (TargetOS == TargetNames.iOS || TargetOS == TargetNames.tvOS); @@ -263,7 +267,7 @@ public override bool Execute() } else { - AppBundlePath = generator.BuildAppBundle(XcodeProjectPath, Optimized, DevTeamProvisioning); + AppBundlePath = generator.BuildAppBundle(XcodeProjectPath, Optimized, StripSymbolTable, DevTeamProvisioning); } } } diff --git a/src/tasks/AppleAppBuilder/Xcode.cs b/src/tasks/AppleAppBuilder/Xcode.cs index 227ff3752d2346..87ee14283e1e5f 100644 --- a/src/tasks/AppleAppBuilder/Xcode.cs +++ b/src/tasks/AppleAppBuilder/Xcode.cs @@ -103,9 +103,13 @@ public string TargetOS /// public string? DestinationFolder { get; set; } + /// Strip local symbols and debug information, and extract it in XcodeProjectPath directory + /// + public bool StripSymbolTable { get; set; } + public override bool Execute() { - new Xcode(Log, TargetOS, Arch).BuildAppBundle(XcodeProjectPath, Optimized, DevTeamProvisioning, DestinationFolder); + new Xcode(Log, TargetOS, Arch).BuildAppBundle(XcodeProjectPath, Optimized, StripSymbolTable, DevTeamProvisioning, DestinationFolder); return true; } @@ -440,7 +444,7 @@ public string GenerateCMake( } public string BuildAppBundle( - string xcodePrjPath, bool optimized, string? devTeamProvisioning = null, string? destination = null) + string xcodePrjPath, bool optimized, bool stripSymbolTable, string? devTeamProvisioning = null, string? destination = null) { string sdk = ""; var args = new StringBuilder(); @@ -545,6 +549,13 @@ public string BuildAppBundle( appPath = newAppPath; } + if (stripSymbolTable) + { + string filename = Path.GetFileNameWithoutExtension(appPath); + Utils.RunProcess(Logger, "dsymutil", $"{appPath}/{filename} -o {Path.GetDirectoryName(xcodePrjPath)}/{filename}.dSYM", workingDir: Path.GetDirectoryName(appPath)); + Utils.RunProcess(Logger, "strip", $"-no_code_signature_warning -x {appPath}/{filename}", workingDir: Path.GetDirectoryName(appPath)); + } + long appSize = new DirectoryInfo(appPath) .EnumerateFiles("*", SearchOption.AllDirectories) .Sum(file => file.Length);