From ede766eb922e0004678139eb7a823e37878ffab2 Mon Sep 17 00:00:00 2001 From: Dustin Wojciechowski Date: Tue, 8 Aug 2023 13:44:32 -0700 Subject: [PATCH 1/5] Added default entitlements for MacCatalyst projects. For Debug, an entitlement that allows for using developer tools when developing blazor apps. For release, entitlements required by Apple to publish to the App Store. Also added unit test to check for entitlements when project is created. --- .../Xamarin.Shared.Sdk.DefaultItems.targets | 14 ++++++++++ tests/dotnet/UnitTests/ProjectTest.cs | 27 +++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/dotnet/targets/Xamarin.Shared.Sdk.DefaultItems.targets b/dotnet/targets/Xamarin.Shared.Sdk.DefaultItems.targets index d100091037f5..ae0c1d17beab 100644 --- a/dotnet/targets/Xamarin.Shared.Sdk.DefaultItems.targets +++ b/dotnet/targets/Xamarin.Shared.Sdk.DefaultItems.targets @@ -23,6 +23,20 @@ + + True + True + + + + + + + + + + + diff --git a/tests/dotnet/UnitTests/ProjectTest.cs b/tests/dotnet/UnitTests/ProjectTest.cs index e6519346e31a..cf71ca485a73 100644 --- a/tests/dotnet/UnitTests/ProjectTest.cs +++ b/tests/dotnet/UnitTests/ProjectTest.cs @@ -1273,6 +1273,33 @@ public void AutoAllowJitEntitlements (ApplePlatform platform, string runtimeIden } } + [TestCase (ApplePlatform.MacCatalyst, "maccatalyst-x64", "Release")] + [TestCase (ApplePlatform.MacCatalyst, "maccatalyst-x64", "Debug")] + public void CheckForMacCatalystDefaultEntitlements(ApplePlatform platform, string runtimeIdentifiers, string configuration) + { + var project = "Entitlements"; + Configuration.IgnoreIfIgnoredPlatform (platform); + Configuration.AssertRuntimeIdentifiersAvailable (platform, runtimeIdentifiers); + + var project_path = GetProjectPath (project, runtimeIdentifiers: runtimeIdentifiers, platform: platform, out var appPath, configuration: configuration); + Clean (project_path); + + var properties = GetDefaultProperties (runtimeIdentifiers); + properties ["Configuration"] = configuration; + DotNet.AssertBuild (project_path, properties); + + var executable = GetNativeExecutable (platform, appPath); + var foundEntitlements = TryGetEntitlements (executable, out var entitlements); + if (configuration == "Release") { + Assert.IsTrue (foundEntitlements, "Found in Release"); + Assert.IsTrue (entitlements!.Get ("com.apple.security.app-sandbox")?.Value, "com.apple.security.app-sandbox enlistment was not found."); + Assert.IsTrue (entitlements!.Get ("com.apple.security.network.client")?.Value, "com.apple.security.network.client enlistment was not found."); + } else if (configuration == "Debug") { + Assert.IsTrue (foundEntitlements, "Found in Debug"); + Assert.IsTrue (entitlements!.Get ("com.apple.security.get-task-allow")?.Value, "com.apple.security.get-task-allow enlistment was not found."); + } + } + // [TestCase (ApplePlatform.MacCatalyst, null, "Release")] [TestCase (ApplePlatform.MacOSX, null, "Release")] public void NoWarnCodesign (ApplePlatform platform, string runtimeIdentifiers, string configuration) From f43ae7641e831d1c84406ec5c7af6f6c8ec322f6 Mon Sep 17 00:00:00 2001 From: GitHub Actions Autoformatter Date: Tue, 8 Aug 2023 20:50:16 +0000 Subject: [PATCH 2/5] Auto-format source code --- src/UIKit/UIMenu.cs | 2 +- tests/dotnet/UnitTests/ProjectTest.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/UIKit/UIMenu.cs b/src/UIKit/UIMenu.cs index 4b2c58108880..c129a28aa112 100644 --- a/src/UIKit/UIMenu.cs +++ b/src/UIKit/UIMenu.cs @@ -15,7 +15,7 @@ public partial class UIMenu { [SupportedOSPlatform ("maccatalyst15.0")] #else [iOS (15, 0)] - [TV (15,0)] + [TV (15, 0)] #endif public virtual UIMenuElement [] SelectedElements { get { diff --git a/tests/dotnet/UnitTests/ProjectTest.cs b/tests/dotnet/UnitTests/ProjectTest.cs index cf71ca485a73..6f5fea9940dc 100644 --- a/tests/dotnet/UnitTests/ProjectTest.cs +++ b/tests/dotnet/UnitTests/ProjectTest.cs @@ -1275,7 +1275,7 @@ public void AutoAllowJitEntitlements (ApplePlatform platform, string runtimeIden [TestCase (ApplePlatform.MacCatalyst, "maccatalyst-x64", "Release")] [TestCase (ApplePlatform.MacCatalyst, "maccatalyst-x64", "Debug")] - public void CheckForMacCatalystDefaultEntitlements(ApplePlatform platform, string runtimeIdentifiers, string configuration) + public void CheckForMacCatalystDefaultEntitlements (ApplePlatform platform, string runtimeIdentifiers, string configuration) { var project = "Entitlements"; Configuration.IgnoreIfIgnoredPlatform (platform); From bcae3c0ec8718d8e3578a99c543c829a564ec0a9 Mon Sep 17 00:00:00 2001 From: Dustin Wojciechowski Date: Mon, 21 Aug 2023 10:03:27 -0700 Subject: [PATCH 3/5] Removed network.client entitlement --- dotnet/targets/Xamarin.Shared.Sdk.DefaultItems.targets | 3 +-- tests/dotnet/UnitTests/ProjectTest.cs | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/dotnet/targets/Xamarin.Shared.Sdk.DefaultItems.targets b/dotnet/targets/Xamarin.Shared.Sdk.DefaultItems.targets index ae0c1d17beab..79ce4a123d99 100644 --- a/dotnet/targets/Xamarin.Shared.Sdk.DefaultItems.targets +++ b/dotnet/targets/Xamarin.Shared.Sdk.DefaultItems.targets @@ -33,8 +33,7 @@ - - + diff --git a/tests/dotnet/UnitTests/ProjectTest.cs b/tests/dotnet/UnitTests/ProjectTest.cs index b2f1d0f8d3be..f471645d1068 100644 --- a/tests/dotnet/UnitTests/ProjectTest.cs +++ b/tests/dotnet/UnitTests/ProjectTest.cs @@ -1290,7 +1290,6 @@ public void CheckForMacCatalystDefaultEntitlements (ApplePlatform platform, stri if (configuration == "Release") { Assert.IsTrue (foundEntitlements, "Found in Release"); Assert.IsTrue (entitlements!.Get ("com.apple.security.app-sandbox")?.Value, "com.apple.security.app-sandbox enlistment was not found."); - Assert.IsTrue (entitlements!.Get ("com.apple.security.network.client")?.Value, "com.apple.security.network.client enlistment was not found."); } else if (configuration == "Debug") { Assert.IsTrue (foundEntitlements, "Found in Debug"); Assert.IsTrue (entitlements!.Get ("com.apple.security.get-task-allow")?.Value, "com.apple.security.get-task-allow enlistment was not found."); From a7ffe68fb9b0188b2b9289823793edeb82f788de Mon Sep 17 00:00:00 2001 From: Dustin Wojciechowski Date: Mon, 21 Aug 2023 11:34:00 -0700 Subject: [PATCH 4/5] Fixed tests --- tests/dotnet/UnitTests/ProjectTest.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/dotnet/UnitTests/ProjectTest.cs b/tests/dotnet/UnitTests/ProjectTest.cs index f471645d1068..1455ab32477a 100644 --- a/tests/dotnet/UnitTests/ProjectTest.cs +++ b/tests/dotnet/UnitTests/ProjectTest.cs @@ -1287,12 +1287,12 @@ public void CheckForMacCatalystDefaultEntitlements (ApplePlatform platform, stri var executable = GetNativeExecutable (platform, appPath); var foundEntitlements = TryGetEntitlements (executable, out var entitlements); + Assert.IsTrue (foundEntitlements, "Issues found with Entitlements."); if (configuration == "Release") { - Assert.IsTrue (foundEntitlements, "Found in Release"); - Assert.IsTrue (entitlements!.Get ("com.apple.security.app-sandbox")?.Value, "com.apple.security.app-sandbox enlistment was not found."); + Assert.IsTrue (entitlements!.Get ("com.apple.security.app-sandbox")?.Value, "com.apple.security.app-sandbox enlistment was not found in Release configuration."); + Assert.IsNull (entitlements.Get ("com.apple.security.get-task-allow")?.Value, "com.apple.security.get-task-allow enlistment was found in Release configuration."); } else if (configuration == "Debug") { - Assert.IsTrue (foundEntitlements, "Found in Debug"); - Assert.IsTrue (entitlements!.Get ("com.apple.security.get-task-allow")?.Value, "com.apple.security.get-task-allow enlistment was not found."); + Assert.IsTrue (entitlements!.Get ("com.apple.security.get-task-allow")?.Value, "com.apple.security.get-task-allow enlistment was not found in Debug configuration."); } } From f84522cbc1db90b4586c431d16e704839b2511b7 Mon Sep 17 00:00:00 2001 From: dustin-wojciechowski Date: Wed, 23 Aug 2023 08:11:04 -0700 Subject: [PATCH 5/5] Update dotnet/targets/Xamarin.Shared.Sdk.DefaultItems.targets Added missing character. Co-authored-by: Rolf Bjarne Kvinge --- dotnet/targets/Xamarin.Shared.Sdk.DefaultItems.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dotnet/targets/Xamarin.Shared.Sdk.DefaultItems.targets b/dotnet/targets/Xamarin.Shared.Sdk.DefaultItems.targets index 79ce4a123d99..3862d66833f7 100644 --- a/dotnet/targets/Xamarin.Shared.Sdk.DefaultItems.targets +++ b/dotnet/targets/Xamarin.Shared.Sdk.DefaultItems.targets @@ -33,7 +33,7 @@ -