diff --git a/dotnet/targets/Xamarin.Shared.Sdk.targets b/dotnet/targets/Xamarin.Shared.Sdk.targets index 490aaa9d0a..27696c8830 100644 --- a/dotnet/targets/Xamarin.Shared.Sdk.targets +++ b/dotnet/targets/Xamarin.Shared.Sdk.targets @@ -364,7 +364,7 @@ Properties=" RuntimeIdentifier=%(_RuntimeIdentifiersAsItems.Identity); _CodesignItemsPath=%(_RuntimeIdentifiersAsItems.RidSpecificCodesignItemsPath); - _MtouchSymbolsList=%(_RuntimeIdentifiersAsItems.RidSpecificSymbolsList); + _MtouchSymbolsList=%(_RuntimeIdentifiersAsItems.RidSpecificSymbolsListPath); _UserFrameworksWithoutDebugSymbolsPath=%(_RuntimeIdentifiersAsItems.RidSpecificUserFrameworksWithoutDebugSymbolsPath); $(_RidSpecificProperties); "> diff --git a/tests/common/Configuration.cs b/tests/common/Configuration.cs index b9976407d9..ac4ee12f6d 100644 --- a/tests/common/Configuration.cs +++ b/tests/common/Configuration.cs @@ -1215,5 +1215,23 @@ namespace Xamarin.Tests { [DllImport ("libc")] static extern int sysctlbyname (string name, ref int value, ref IntPtr size, IntPtr zero, IntPtr zeroAgain); + + public static IEnumerable GetNativeSymbols (string file, string arch = null) + { + var arguments = new List (new [] { "-gUjA", file }); + if (!string.IsNullOrEmpty (arch)) { + arguments.Add ("-arch"); + arguments.Add (arch); + } + var symbols = ExecutionHelper.Execute ("nm", arguments, hide_output: true).Split ('\n'); + return symbols.Where ((v) => { + return !v.EndsWith (": no symbols", StringComparison.Ordinal); + }).Select ((v) => { + var idx = v.LastIndexOf (": ", StringComparison.Ordinal); + if (idx <= 0) + return v; + return v.Substring (idx + 2); + }); + } } } diff --git a/tests/dotnet/UnitTests/ProjectTest.cs b/tests/dotnet/UnitTests/ProjectTest.cs index 6adccd5b8c..b4c6933551 100644 --- a/tests/dotnet/UnitTests/ProjectTest.cs +++ b/tests/dotnet/UnitTests/ProjectTest.cs @@ -1634,5 +1634,32 @@ namespace Xamarin.Tests { AssertErrorCount (errors, 1, "Error count"); AssertErrorMessages (errors, $"The property '{property}' is deprecated, please remove it from the project file. Use 'RuntimeIdentifier' or 'RuntimeIdentifiers' instead to specify the target architecture."); } + + [Test] + // The trailing semi-colon for single-arch platforms is significant: + // it means we'll use "RuntimeIdentifiers" (plural) instead of "RuntimeIdentifier" (singular) + [TestCase (ApplePlatform.iOS, "ios-arm64;")] + [TestCase (ApplePlatform.MacOSX, "osx-arm64;osx-x64")] + [TestCase (ApplePlatform.MacCatalyst, "maccatalyst-x64;")] + [TestCase (ApplePlatform.TVOS, "tvos-arm64;")] + public void StrippedRuntimeIdentifiers (ApplePlatform platform, string runtimeIdentifiers) + { + var project = "MySimpleApp"; + Configuration.IgnoreIfIgnoredPlatform (platform); + Configuration.AssertRuntimeIdentifiersAvailable (platform, runtimeIdentifiers); + + var project_path = GetProjectPath (project, runtimeIdentifiers: runtimeIdentifiers, platform: platform, out var appPath); + Clean (project_path); + var properties = GetDefaultProperties (runtimeIdentifiers); + properties ["NoSymbolStrip"] = "false"; + DotNet.AssertBuild (project_path, properties); + + var appExecutable = GetNativeExecutable (platform, appPath); + ExecuteWithMagicWordAndAssert (platform, runtimeIdentifiers, appExecutable); + + var symbols = Configuration.GetNativeSymbols (appExecutable); + Assert.That (symbols, Does.Contain ("_xamarin_release_managed_ref"), "_xamarin_release_managed_ref"); + } + } } diff --git a/tests/mtouch/MTouch.cs b/tests/mtouch/MTouch.cs index 0e5f940e61..c77afd80c2 100644 --- a/tests/mtouch/MTouch.cs +++ b/tests/mtouch/MTouch.cs @@ -4715,20 +4715,7 @@ public class TestApp { public static IEnumerable GetNativeSymbols (string file, string arch = null) { - var arguments = new List (new [] { "-gUjA", file }); - if (!string.IsNullOrEmpty (arch)) { - arguments.Add ("-arch"); - arguments.Add (arch); - } - var symbols = ExecutionHelper.Execute ("nm", arguments, hide_output: true).Split ('\n'); - return symbols.Where ((v) => { - return !v.EndsWith (": no symbols", StringComparison.Ordinal); - }).Select ((v) => { - var idx = v.LastIndexOf (": ", StringComparison.Ordinal); - if (idx <= 0) - return v; - return v.Substring (idx + 2); - }); + return Configuration.GetNativeSymbols (file, arch); } static bool? is_apfs;