diff --git a/external/Xamarin.MacDev b/external/Xamarin.MacDev index 9e6e29f2a4e..0717ac3c249 160000 --- a/external/Xamarin.MacDev +++ b/external/Xamarin.MacDev @@ -1 +1 @@ -Subproject commit 9e6e29f2a4e89b140cb37575168faccc70c45d5f +Subproject commit 0717ac3c249595b48860904ce77000a6115affbe diff --git a/msbuild/Xamarin.Localization.MSBuild/MSBStrings.Designer.cs b/msbuild/Xamarin.Localization.MSBuild/MSBStrings.Designer.cs index 8d0d80d6b0b..5e2de9d6f77 100644 --- a/msbuild/Xamarin.Localization.MSBuild/MSBStrings.Designer.cs +++ b/msbuild/Xamarin.Localization.MSBuild/MSBStrings.Designer.cs @@ -2002,6 +2002,24 @@ public static string E7094 { } } + /// + /// Looks up a localized string similar to The UIDeviceFamily value '6' is not valid for this platform. It's only valid for Mac Catalyst.. + /// + public static string E7098 { + get { + return ResourceManager.GetString("E7098", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The UIDeviceFamily value '6' requires macOS 11.0. Please set the 'SupportedOSPlatformVersion' in the project file to at least 14.0 (the Mac Catalyst version equivalent of macOS 11.0). The current value is {0} (equivalent to macOS {1}).. + /// + public static string E7099 { + get { + return ResourceManager.GetString("E7099", resourceCulture); + } + } + /// /// Looks up a localized string similar to Invalid framework: {0}. /// diff --git a/msbuild/Xamarin.Localization.MSBuild/MSBStrings.resx b/msbuild/Xamarin.Localization.MSBuild/MSBStrings.resx index e1f7331997f..1514306c5fd 100644 --- a/msbuild/Xamarin.Localization.MSBuild/MSBStrings.resx +++ b/msbuild/Xamarin.Localization.MSBuild/MSBStrings.resx @@ -1407,4 +1407,12 @@ Code signing has been requested multiple times for '{0}', with different metadata. The metadata '{1}' has been values for each item (once it's '{2}', another time it's '{3}'). + + + The UIDeviceFamily value '6' is not valid for this platform. It's only valid for Mac Catalyst. + + + + The UIDeviceFamily value '6' requires macOS 11.0. Please set the 'SupportedOSPlatformVersion' in the project file to at least 14.0 (the Mac Catalyst version equivalent of macOS 11.0). The current value is {0} (equivalent to macOS {1}). + diff --git a/msbuild/Xamarin.MacDev.Tasks.Core/Tasks/CompileAppManifestTaskBase.cs b/msbuild/Xamarin.MacDev.Tasks.Core/Tasks/CompileAppManifestTaskBase.cs index e5190c93ffe..a63b5946bd6 100644 --- a/msbuild/Xamarin.MacDev.Tasks.Core/Tasks/CompileAppManifestTaskBase.cs +++ b/msbuild/Xamarin.MacDev.Tasks.Core/Tasks/CompileAppManifestTaskBase.cs @@ -377,6 +377,22 @@ void Validation (PDictionary plist) return; var supportedDevices = plist.GetUIDeviceFamily (); + var macCatalystOptimizedForMac = (supportedDevices & IPhoneDeviceType.MacCatalystOptimizedForMac) == IPhoneDeviceType.MacCatalystOptimizedForMac; + if (macCatalystOptimizedForMac) { + if (Platform != ApplePlatform.MacCatalyst) { + LogAppManifestError (MSBStrings.E7098 /* The UIDeviceFamily value '6' is not valid for this platform. It's only valid for Mac Catalyst. */); + return; // no need to look for more errors, they will probably not make much sense. + } + + GetMinimumOSVersion (plist, out var minimumOSVersion); + if (minimumOSVersion < new Version (11, 0)) { + string miniOSVersion = "?"; + if (MacCatalystSupport.TryGetiOSVersion (Sdks.GetAppleSdk (Platform).GetSdkPath (SdkVersion, false), minimumOSVersion, out var iOSVersion, out var _)) + miniOSVersion = iOSVersion.ToString (); + LogAppManifestError (MSBStrings.E7099 /* The UIDeviceFamily value '6' requires macOS 11.0. Please set the 'SupportedOSPlatformVersion' in the project file to at least 14.0 (the Mac Catalyst version equivalent of macOS 11.0). The current value is {0} (equivalent to macOS {1}). */, miniOSVersion, minimumOSVersion); + } + } + switch (Platform) { case ApplePlatform.iOS: var supportsIPhone = (supportedDevices & IPhoneDeviceType.IPhone) != 0 diff --git a/tests/common/shared-dotnet.csproj b/tests/common/shared-dotnet.csproj index 4ec268999e9..03e03134aec 100644 --- a/tests/common/shared-dotnet.csproj +++ b/tests/common/shared-dotnet.csproj @@ -8,7 +8,7 @@ xamarinios10;$(AssetTargetFallback) ios-fat - 10.0 + 10.0 $(MSBuildThisFileDirectory)\..\..\src\build\dotnet\ios-defines-dotnet.rsp @@ -18,7 +18,7 @@ xamarintvos10;$(AssetTargetFallback) tvos-fat - 10.0 + 10.0 $(MSBuildThisFileDirectory)\..\..\src\build\dotnet\tvos-defines-dotnet.rsp @@ -28,7 +28,7 @@ $(DefineConstants);MONOMAC macos-fat - 10.14 + 10.14 $(MSBuildThisFileDirectory)\..\..\src\build\dotnet\macos-defines-dotnet.rsp @@ -36,7 +36,7 @@ xamarinios10;$(AssetTargetFallback) maccatalyst-fat - 13.3 + 13.3 $(MSBuildThisFileDirectory)\..\..\src\build\dotnet\maccatalyst-defines-dotnet.rsp diff --git a/tests/dotnet/CatalystAppOptimizedForMacOS/AppDelegate.cs b/tests/dotnet/CatalystAppOptimizedForMacOS/AppDelegate.cs new file mode 100644 index 00000000000..24a52b91ba7 --- /dev/null +++ b/tests/dotnet/CatalystAppOptimizedForMacOS/AppDelegate.cs @@ -0,0 +1,19 @@ +using System; +using System.Runtime.InteropServices; + +using Foundation; + +namespace MySimpleApp +{ + public class Program + { + static int Main (string[] args) + { + GC.KeepAlive (typeof (NSObject)); // prevent linking away the platform assembly + + Console.WriteLine (Environment.GetEnvironmentVariable ("MAGIC_WORD")); + + return args.Length; + } + } +} diff --git a/tests/dotnet/CatalystAppOptimizedForMacOS/Info.plist b/tests/dotnet/CatalystAppOptimizedForMacOS/Info.plist new file mode 100644 index 00000000000..548db2d1342 --- /dev/null +++ b/tests/dotnet/CatalystAppOptimizedForMacOS/Info.plist @@ -0,0 +1,10 @@ + + + + + UIDeviceFamily + + 6 + + + diff --git a/tests/dotnet/CatalystAppOptimizedForMacOS/MacCatalyst/CatalystAppOptimizedForMacOS.csproj b/tests/dotnet/CatalystAppOptimizedForMacOS/MacCatalyst/CatalystAppOptimizedForMacOS.csproj new file mode 100644 index 00000000000..2b5744d9838 --- /dev/null +++ b/tests/dotnet/CatalystAppOptimizedForMacOS/MacCatalyst/CatalystAppOptimizedForMacOS.csproj @@ -0,0 +1,8 @@ + + + + net$(BundledNETCoreAppTargetFrameworkVersion)-maccatalyst + 14.0 + + + diff --git a/tests/dotnet/CatalystAppOptimizedForMacOS/MacCatalyst/Makefile b/tests/dotnet/CatalystAppOptimizedForMacOS/MacCatalyst/Makefile new file mode 100644 index 00000000000..110d078f457 --- /dev/null +++ b/tests/dotnet/CatalystAppOptimizedForMacOS/MacCatalyst/Makefile @@ -0,0 +1 @@ +include ../shared.mk diff --git a/tests/dotnet/CatalystAppOptimizedForMacOS/Makefile b/tests/dotnet/CatalystAppOptimizedForMacOS/Makefile new file mode 100644 index 00000000000..6affa45ff12 --- /dev/null +++ b/tests/dotnet/CatalystAppOptimizedForMacOS/Makefile @@ -0,0 +1,2 @@ +TOP=../../.. +include $(TOP)/tests/common/shared-dotnet-test.mk diff --git a/tests/dotnet/CatalystAppOptimizedForMacOS/iOS/CatalystAppOptimizedForMacOS.csproj b/tests/dotnet/CatalystAppOptimizedForMacOS/iOS/CatalystAppOptimizedForMacOS.csproj new file mode 100644 index 00000000000..86d408734aa --- /dev/null +++ b/tests/dotnet/CatalystAppOptimizedForMacOS/iOS/CatalystAppOptimizedForMacOS.csproj @@ -0,0 +1,7 @@ + + + + net$(BundledNETCoreAppTargetFrameworkVersion)-ios + + + diff --git a/tests/dotnet/CatalystAppOptimizedForMacOS/iOS/Makefile b/tests/dotnet/CatalystAppOptimizedForMacOS/iOS/Makefile new file mode 100644 index 00000000000..110d078f457 --- /dev/null +++ b/tests/dotnet/CatalystAppOptimizedForMacOS/iOS/Makefile @@ -0,0 +1 @@ +include ../shared.mk diff --git a/tests/dotnet/CatalystAppOptimizedForMacOS/macOS/CatalystAppOptimizedForMacOS.csproj b/tests/dotnet/CatalystAppOptimizedForMacOS/macOS/CatalystAppOptimizedForMacOS.csproj new file mode 100644 index 00000000000..a77287b9ba0 --- /dev/null +++ b/tests/dotnet/CatalystAppOptimizedForMacOS/macOS/CatalystAppOptimizedForMacOS.csproj @@ -0,0 +1,7 @@ + + + + net$(BundledNETCoreAppTargetFrameworkVersion)-macos + + + diff --git a/tests/dotnet/CatalystAppOptimizedForMacOS/macOS/Makefile b/tests/dotnet/CatalystAppOptimizedForMacOS/macOS/Makefile new file mode 100644 index 00000000000..110d078f457 --- /dev/null +++ b/tests/dotnet/CatalystAppOptimizedForMacOS/macOS/Makefile @@ -0,0 +1 @@ +include ../shared.mk diff --git a/tests/dotnet/CatalystAppOptimizedForMacOS/shared.csproj b/tests/dotnet/CatalystAppOptimizedForMacOS/shared.csproj new file mode 100644 index 00000000000..7f34bf8af32 --- /dev/null +++ b/tests/dotnet/CatalystAppOptimizedForMacOS/shared.csproj @@ -0,0 +1,16 @@ + + + + Exe + + CatalystAppOptimizedForMacOS + com.xamarin.catalystappoptimizedformacos + + + + + + + + + diff --git a/tests/dotnet/CatalystAppOptimizedForMacOS/shared.mk b/tests/dotnet/CatalystAppOptimizedForMacOS/shared.mk new file mode 100644 index 00000000000..f555cad4e80 --- /dev/null +++ b/tests/dotnet/CatalystAppOptimizedForMacOS/shared.mk @@ -0,0 +1,2 @@ +TOP=../../../.. +include $(TOP)/tests/common/shared-dotnet.mk diff --git a/tests/dotnet/CatalystAppOptimizedForMacOS/tvOS/CatalystAppOptimizedForMacOS.csproj b/tests/dotnet/CatalystAppOptimizedForMacOS/tvOS/CatalystAppOptimizedForMacOS.csproj new file mode 100644 index 00000000000..bd487ddcd88 --- /dev/null +++ b/tests/dotnet/CatalystAppOptimizedForMacOS/tvOS/CatalystAppOptimizedForMacOS.csproj @@ -0,0 +1,7 @@ + + + + net$(BundledNETCoreAppTargetFrameworkVersion)-tvos + + + diff --git a/tests/dotnet/CatalystAppOptimizedForMacOS/tvOS/Makefile b/tests/dotnet/CatalystAppOptimizedForMacOS/tvOS/Makefile new file mode 100644 index 00000000000..110d078f457 --- /dev/null +++ b/tests/dotnet/CatalystAppOptimizedForMacOS/tvOS/Makefile @@ -0,0 +1 @@ +include ../shared.mk diff --git a/tests/dotnet/UnitTests/ProjectTest.cs b/tests/dotnet/UnitTests/ProjectTest.cs index 11872399c64..bb5ddd20eb3 100644 --- a/tests/dotnet/UnitTests/ProjectTest.cs +++ b/tests/dotnet/UnitTests/ProjectTest.cs @@ -889,5 +889,43 @@ public void CentralPackageVersionsApp (ApplePlatform platform) var properties = GetDefaultProperties (); DotNet.AssertBuild (project_path, properties); } + + [TestCase (ApplePlatform.MacCatalyst, "maccatalyst-x64", false)] + [TestCase (ApplePlatform.iOS, "iossimulator-x64", true)] + [TestCase (ApplePlatform.TVOS, "tvossimulator-x64", true)] + [TestCase (ApplePlatform.MacOSX, "osx-x64;osx-arm64", true)] + public void CatalystAppOptimizedForMacOS (ApplePlatform platform, string runtimeIdentifier, bool failureExpected) + { + var project = "CatalystAppOptimizedForMacOS"; + Configuration.IgnoreIfIgnoredPlatform (platform); + + var project_path = GetProjectPath (project, platform: platform); + Clean (project_path); + var properties = GetDefaultProperties (runtimeIdentifier); + if (failureExpected) { + var rv = DotNet.AssertBuildFailure (project_path, properties); + var errors = BinLog.GetBuildLogErrors (rv.BinLogPath).ToArray (); + Assert.AreEqual (1, errors.Length, "Error count"); + Assert.AreEqual ($"The UIDeviceFamily value '6' is not valid for this platform. It's only valid for Mac Catalyst.", errors [0].Message, "Error message"); + } else { + DotNet.AssertBuild (project_path, properties); + } + } + + [TestCase (ApplePlatform.MacCatalyst, "maccatalyst-x64", "13.3")] + public void CatalystAppOptimizedForMacOS_InvalidMinOS (ApplePlatform platform, string runtimeIdentifier, string minOS) + { + var project = "CatalystAppOptimizedForMacOS"; + Configuration.IgnoreIfIgnoredPlatform (platform); + + var project_path = GetProjectPath (project, platform: platform); + Clean (project_path); + var properties = GetDefaultProperties (runtimeIdentifier); + properties ["SupportedOSPlatformVersion"] = minOS; + var rv = DotNet.AssertBuildFailure (project_path, properties); + var errors = BinLog.GetBuildLogErrors (rv.BinLogPath).ToArray (); + Assert.AreEqual (1, errors.Length, "Error count"); + Assert.AreEqual ($"The UIDeviceFamily value '6' requires macOS 11.0. Please set the 'SupportedOSPlatformVersion' in the project file to at least 14.0 (the Mac Catalyst version equivalent of macOS 11.0). The current value is {minOS} (equivalent to macOS 10.15.2).", errors [0].Message, "Error message"); + } } }