From 02e14e6e777516f648359466b7f9bb0fa4ccf3fe Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Tue, 25 Jun 2024 14:30:47 +0200 Subject: [PATCH] [msbuild] Update values we put in the generated Info.plist for Xcode archives. (#20719) * Set the Architectures array, which Xcode does. This requires passing RuntimeIdentifier(s) to the task, so do that. * Set SchemeName, which Xcode does. This is a partial fix for https://github.com/xamarin/xamarin-macios/issues/20714. --------- Co-authored-by: Alex Soto --- .../MSBStrings.resx | 6 ++++++ msbuild/Xamarin.MacDev.Tasks/Tasks/Archive.cs | 20 +++++++++++++++++++ msbuild/Xamarin.Shared/Xamarin.Shared.targets | 1 + 3 files changed, 27 insertions(+) diff --git a/msbuild/Xamarin.Localization.MSBuild/MSBStrings.resx b/msbuild/Xamarin.Localization.MSBuild/MSBStrings.resx index c68bc70506c2..77820e2cd6cc 100644 --- a/msbuild/Xamarin.Localization.MSBuild/MSBStrings.resx +++ b/msbuild/Xamarin.Localization.MSBuild/MSBStrings.resx @@ -1559,4 +1559,10 @@ The app bundle '{0}' contains a subdirectory named 'Resources'. This is not allowed on this platform. Typically resource files should be in the root directory of the app bundle (or a custom subdirectory, but named anything other than 'Resources'). 0: a path + + + Can't compute the architecture for the archive for the RuntimeIdentifier '{0}' (unknown value) + RuntimeIdentifier: don't translate (it's the name of a MSBuild property) + + diff --git a/msbuild/Xamarin.MacDev.Tasks/Tasks/Archive.cs b/msbuild/Xamarin.MacDev.Tasks/Tasks/Archive.cs index 44351809f660..c64f862ea421 100644 --- a/msbuild/Xamarin.MacDev.Tasks/Tasks/Archive.cs +++ b/msbuild/Xamarin.MacDev.Tasks/Tasks/Archive.cs @@ -42,6 +42,8 @@ public class Archive : XamarinTask, ICancelableTask { public string ProjectTypeGuids { get; set; } + public string RuntimeIdentifiers { get; set; } + public string SolutionPath { get; set; } public string SigningKey { get; set; } @@ -190,6 +192,23 @@ public override bool Execute () //arInfo.Add ("AppStoreFileSize", new PNumber (65535)); var props = new PDictionary (); props.Add ("ApplicationPath", new PString (string.Format ("Applications/{0}", Path.GetFileName (AppBundleDir.ItemSpec)))); + if (!string.IsNullOrEmpty (RuntimeIdentifiers) && IsDotNet) { + var rids = RuntimeIdentifiers.Split (new char [] { ';' }, StringSplitOptions.RemoveEmptyEntries); + var array = new PArray (); + foreach (var rid in rids) { + string architecture; + if (rid.EndsWith ("-x64", StringComparison.Ordinal)) { + architecture = "x86_64"; + } else if (rid.EndsWith ("-arm64", StringComparison.Ordinal)) { + architecture = "arm64"; + } else { + Log.LogError (MSBStrings.E7124 /* Can't compute the architecture for the archive for the RuntimeIdentifier '{0}' (unknown value) */, rid); + continue; + } + array.Add (new PString (architecture)); + } + props.Add ("Architectures", array); + } props.Add ("CFBundleIdentifier", new PString (plist.GetCFBundleIdentifier ())); var version = plist.GetCFBundleShortVersionString (); @@ -220,6 +239,7 @@ public override bool Execute () arInfo.Add ("ArchiveVersion", new PNumber (2)); arInfo.Add ("CreationDate", new PDate (Now.ToUniversalTime ())); arInfo.Add ("Name", new PString (plist.GetCFBundleName () ?? plist.GetCFBundleDisplayName ())); + arInfo.Add ("SchemeName", new PString (plist.GetCFBundleName () ?? plist.GetCFBundleDisplayName ())); if (!string.IsNullOrEmpty (ProjectGuid)) arInfo.Add ("ProjectGuid", new PString (ProjectGuid)); diff --git a/msbuild/Xamarin.Shared/Xamarin.Shared.targets b/msbuild/Xamarin.Shared/Xamarin.Shared.targets index cffc5354bf87..0487153b9bda 100644 --- a/msbuild/Xamarin.Shared/Xamarin.Shared.targets +++ b/msbuild/Xamarin.Shared/Xamarin.Shared.targets @@ -2919,6 +2919,7 @@ Copyright (C) 2018 Microsoft. All rights reserved. ProjectTypeGuids="$(ProjectTypeGuids)" SigningKey="$(_CodeSigningKey)" SolutionPath="$(SolutionPath)" + RuntimeIdentifiers="$(RuntimeIdentifiers);$(RuntimeIdentifier)" TargetFrameworkMoniker="$(_ComputedTargetFrameworkMoniker)" WatchAppReferences="@(_ResolvedWatchAppReferences)" >