Skip to content

Commit

Permalink
[msbuild] Update values we put in the generated Info.plist for Xcode …
Browse files Browse the repository at this point in the history
…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 #20714.

---------

Co-authored-by: Alex Soto <alex@alexsoto.me>
  • Loading branch information
rolfbjarne and dalexsoto authored Jun 25, 2024
1 parent 3138e62 commit 02e14e6
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
6 changes: 6 additions & 0 deletions msbuild/Xamarin.Localization.MSBuild/MSBStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1559,4 +1559,10 @@
<value>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').</value>
<comment>0: a path</comment>
</data>

<data name="E7124" xml:space="preserve">
<value>Can't compute the architecture for the archive for the RuntimeIdentifier '{0}' (unknown value)</value>
<comment>RuntimeIdentifier: don't translate (it's the name of a MSBuild property)</comment>
</data>

</root>
20 changes: 20 additions & 0 deletions msbuild/Xamarin.MacDev.Tasks/Tasks/Archive.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down Expand Up @@ -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 ();
Expand Down Expand Up @@ -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));
Expand Down
1 change: 1 addition & 0 deletions msbuild/Xamarin.Shared/Xamarin.Shared.targets
Original file line number Diff line number Diff line change
Expand Up @@ -2919,6 +2919,7 @@ Copyright (C) 2018 Microsoft. All rights reserved.
ProjectTypeGuids="$(ProjectTypeGuids)"
SigningKey="$(_CodeSigningKey)"
SolutionPath="$(SolutionPath)"
RuntimeIdentifiers="$(RuntimeIdentifiers);$(RuntimeIdentifier)"
TargetFrameworkMoniker="$(_ComputedTargetFrameworkMoniker)"
WatchAppReferences="@(_ResolvedWatchAppReferences)"
>
Expand Down

8 comments on commit 02e14e6

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

Please sign in to comment.