Skip to content

Commit 65d1831

Browse files
mattleibowCopilot
andcommitted
Add net8.0-maccatalyst TFM to Microsoft.Identity.Client
Add Mac Catalyst target framework moniker (net8.0-maccatalyst) to the main MSAL.NET library. Mac Catalyst uses UIKit like iOS, so the existing iOS platform code (keychain, broker, webviews, HTTP client) is reused directly without duplication. Changes: - Add TargetFrameworkNetMacCatalyst property and include in multi-target builds - Define MACCATALYST and iOS compilation symbols for Mac Catalyst - Add SupportedOSPlatformVersion 14.0 for Mac Catalyst - Reuse Platforms/iOS source files for Mac Catalyst target - Add JSON build infrastructure DefineConstants (same as iOS) - Create PublicApi/net8.0-maccatalyst tracking files (copied from iOS) - Differentiate product name telemetry (MSAL.MacCatalyst vs MSAL.Xamarin.iOS) - Update MAUI sample apps from net6.0 to net8.0 TFMs - Update CI mac build template with maccatalyst workload and build steps This enables Mac Catalyst apps to get full platform-specific MSAL functionality (keychain token caching, ASWebAuthenticationSession, broker support, NSUrlSessionHandler) instead of falling back to the generic netstandard2.0 build. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 787cabf commit 65d1831

9 files changed

Lines changed: 1170 additions & 12 deletions

File tree

build/platform_and_feature_flags.props

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,13 @@
1717
<PropertyGroup Condition="'$(TargetFramework)' == '$(TargetFrameworkNetIos)'">
1818
<DefineConstants>$(DefineConstants);iOS;SUPPORTS_BROKER</DefineConstants>
1919
</PropertyGroup>
20+
<PropertyGroup Condition="'$(TargetFramework)' == '$(TargetFrameworkNetMacCatalyst)'">
21+
<DefineConstants>$(DefineConstants);MACCATALYST;iOS;SUPPORTS_BROKER</DefineConstants>
22+
</PropertyGroup>
2023
<PropertyGroup Condition="'$(TargetFramework)' == '$(TargetFrameworkNetStandard)'">
2124
<DefineConstants>$(DefineConstants);NETSTANDARD;SUPPORTS_CONFIDENTIAL_CLIENT;SUPPORTS_BROKER;SUPPORTS_CUSTOM_CACHE;SUPPORTS_WIN32;</DefineConstants>
2225
</PropertyGroup>
23-
<PropertyGroup Condition="'$(TargetFramework)' == '$(TargetFrameworkNetAndroid)' or '$(TargetFramework)' == '$(TargetFrameworkNetIos)'">
26+
<PropertyGroup Condition="'$(TargetFramework)' == '$(TargetFrameworkNetAndroid)' or '$(TargetFramework)' == '$(TargetFrameworkNetIos)' or '$(TargetFramework)' == '$(TargetFrameworkNetMacCatalyst)'">
2427
<DefineConstants>$(DefineConstants);MOBILE</DefineConstants>
2528
</PropertyGroup>
2629
</Project>

build/template-build-on-mac.yaml

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# template-build-on-mac.yaml
2-
# Build tests\devapps\MacConsoleAppWithBroker\MacConsoleAppWithBroker.csproj on macOS
2+
# Build macOS projects on macOS:
3+
# - tests\devapps\MacConsoleAppWithBroker\MacConsoleAppWithBroker.csproj
4+
# - tests\devapps\MacMauiAppWithBroker\MacMauiAppWithBroker.csproj (Mac Catalyst)
5+
# - src\client\Microsoft.Identity.Client\Microsoft.Identity.Client.csproj (Mac Catalyst TFM)
36

47
parameters:
58
BuildConfiguration: 'Release'
@@ -16,6 +19,13 @@ steps:
1619
inputs:
1720
version: 8.x
1821

22+
- task: DotNetCoreCLI@2
23+
displayName: 'Install maccatalyst workload'
24+
inputs:
25+
command: 'custom'
26+
custom: 'workload'
27+
arguments: 'install maccatalyst'
28+
1929
- task: DotNetCoreCLI@2
2030
displayName: 'Restore mac console app with broker'
2131
inputs:
@@ -29,3 +39,29 @@ steps:
2939
command: 'build'
3040
projects: |
3141
./tests/devapps/MacConsoleAppWithBroker/MacConsoleAppWithBroker.csproj
42+
43+
- task: DotNetCoreCLI@2
44+
displayName: 'Build MSAL library for Mac Catalyst TFM'
45+
inputs:
46+
command: 'build'
47+
projects: |
48+
./src/client/Microsoft.Identity.Client/Microsoft.Identity.Client.csproj
49+
arguments: '-f net8.0-maccatalyst -p:INCLUDE_MOBILE_AND_LEGACY_TFM=true'
50+
env:
51+
INCLUDE_MOBILE_AND_LEGACY_TFM: 'true'
52+
53+
- task: DotNetCoreCLI@2
54+
displayName: 'Restore mac MAUI app with broker'
55+
inputs:
56+
command: 'custom'
57+
custom: 'workload'
58+
arguments: 'restore ./tests/devapps/MacMauiAppWithBroker/MacMauiAppWithBroker.csproj'
59+
60+
- task: DotNetCoreCLI@2
61+
displayName: 'Build mac MAUI app with broker'
62+
inputs:
63+
command: 'build'
64+
projects: |
65+
./tests/devapps/MacMauiAppWithBroker/MacMauiAppWithBroker.csproj
66+
env:
67+
INCLUDE_MOBILE_AND_LEGACY_TFM: 'true'

src/client/Microsoft.Identity.Client/Microsoft.Identity.Client.csproj

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,19 @@
1212
<PropertyGroup Condition="'$(INCLUDE_MOBILE_AND_LEGACY_TFM)' != ''">
1313
<TargetFrameworkNetAndroid>net8.0-android</TargetFrameworkNetAndroid>
1414
<TargetFrameworkNetIos>net8.0-ios</TargetFrameworkNetIos>
15+
<TargetFrameworkNetMacCatalyst>net8.0-maccatalyst</TargetFrameworkNetMacCatalyst>
1516
</PropertyGroup>
1617

1718
<!-- mobile SDK constraints -->
18-
<PropertyGroup Condition="'$(TargetFramework)' == '$(TargetFrameworkNetIos)' or '$(TargetFramework)' == '$(TargetFrameworkNetAndroid)'">
19+
<PropertyGroup Condition="'$(TargetFramework)' == '$(TargetFrameworkNetIos)' or '$(TargetFramework)' == '$(TargetFrameworkNetAndroid)' or '$(TargetFramework)' == '$(TargetFrameworkNetMacCatalyst)'">
1920
<SupportedOSPlatformVersion Condition="'$(TargetFramework)' == '$(TargetFrameworkNetIos)'">14.2</SupportedOSPlatformVersion>
2021
<SupportedOSPlatformVersion Condition="'$(TargetFramework)' == '$(TargetFrameworkNetAndroid)'">21.0</SupportedOSPlatformVersion>
22+
<SupportedOSPlatformVersion Condition="'$(TargetFramework)' == '$(TargetFrameworkNetMacCatalyst)'">14.0</SupportedOSPlatformVersion>
2123
</PropertyGroup>
2224

2325
<PropertyGroup>
24-
<TargetFrameworks Condition="$([MSBuild]::IsOsPlatform('Windows'))">$(TargetFrameworkNetDesktop462);$(TargetFrameworkNetDesktop472);$(TargetFrameworkNetStandard);$(TargetFrameworkNetIos);$(TargetFrameworkNetAndroid);$(TargetFrameworkNet);</TargetFrameworks>
25-
<TargetFrameworks Condition="$([MSBuild]::IsOsPlatform('OSX'))">$(TargetFrameworkNetStandard);$(TargetFrameworkNetIos);$(TargetFrameworkNetAndroid);$(TargetFrameworkNet)</TargetFrameworks>
26+
<TargetFrameworks Condition="$([MSBuild]::IsOsPlatform('Windows'))">$(TargetFrameworkNetDesktop462);$(TargetFrameworkNetDesktop472);$(TargetFrameworkNetStandard);$(TargetFrameworkNetIos);$(TargetFrameworkNetMacCatalyst);$(TargetFrameworkNetAndroid);$(TargetFrameworkNet);</TargetFrameworks>
27+
<TargetFrameworks Condition="$([MSBuild]::IsOsPlatform('OSX'))">$(TargetFrameworkNetStandard);$(TargetFrameworkNetIos);$(TargetFrameworkNetMacCatalyst);$(TargetFrameworkNetAndroid);$(TargetFrameworkNet)</TargetFrameworks>
2628
<TargetFrameworks Condition="$([MSBuild]::IsOsPlatform('Linux')) Or '$(NetCoreOnly)' !='' ">$(TargetFrameworkNetStandard);$(TargetFrameworkNet)</TargetFrameworks>
2729
</PropertyGroup>
2830

@@ -64,6 +66,10 @@
6466
<!-- These are for MSAL json/* build infra -->
6567
<DefineConstants>$(DefineConstants);HAVE_ASYNC;HAVE_BINARY_SERIALIZATION;HAVE_COVARIANT_GENERICS;HAVE_DATA_CONTRACTS;HAVE_DATE_TIME_OFFSET;HAVE_DYNAMIC;HAVE_EXPRESSIONS;HAVE_FSHARP_TYPES;HAVE_GUID_TRY_PARSE;HAVE_HASH_SET;HAVE_IGNORE_DATA_MEMBER_ATTRIBUTE;HAVE_INOTIFY_COLLECTION_CHANGED;HAVE_INOTIFY_PROPERTY_CHANGING;HAVE_ISET;HAVE_LINQ;HAVE_METHOD_IMPL_ATTRIBUTE;HAVE_NON_SERIALIZED_ATTRIBUTE;HAVE_READ_ONLY_COLLECTIONS;HAVE_REFLECTION_BINDER;HAVE_SERIALIZATION_BINDER_BIND_TO_NAME;HAVE_STRING_JOIN_WITH_ENUMERABLE;HAVE_TIME_SPAN_PARSE_WITH_CULTURE;HAVE_TIME_SPAN_TO_STRING_WITH_CULTURE;HAVE_TIME_ZONE_INFO;HAVE_UNICODE_SURROGATE_DETECTION;HAVE_VARIANT_TYPE_PARAMETERS;HAVE_VERSION_TRY_PARSE;HAVE_XLINQ;HAVE_XML_DOCUMENT;HAVE_CONCURRENT_DICTIONARY;HAVE_ICONVERTIBLE;HAVE_XML_DOCUMENT_TYPE;$(AdditionalConstants)</DefineConstants>
6668
</PropertyGroup>
69+
<PropertyGroup Condition="'$(TargetFramework)' == '$(TargetFrameworkNetMacCatalyst)'">
70+
<!-- These are for MSAL json/* build infra - same capabilities as iOS since Mac Catalyst uses UIKit -->
71+
<DefineConstants>$(DefineConstants);HAVE_ASYNC;HAVE_BINARY_SERIALIZATION;HAVE_COVARIANT_GENERICS;HAVE_DATA_CONTRACTS;HAVE_DATE_TIME_OFFSET;HAVE_DYNAMIC;HAVE_EXPRESSIONS;HAVE_FSHARP_TYPES;HAVE_GUID_TRY_PARSE;HAVE_HASH_SET;HAVE_IGNORE_DATA_MEMBER_ATTRIBUTE;HAVE_INOTIFY_COLLECTION_CHANGED;HAVE_INOTIFY_PROPERTY_CHANGING;HAVE_ISET;HAVE_LINQ;HAVE_METHOD_IMPL_ATTRIBUTE;HAVE_NON_SERIALIZED_ATTRIBUTE;HAVE_READ_ONLY_COLLECTIONS;HAVE_REFLECTION_BINDER;HAVE_SERIALIZATION_BINDER_BIND_TO_NAME;HAVE_STRING_JOIN_WITH_ENUMERABLE;HAVE_TIME_SPAN_PARSE_WITH_CULTURE;HAVE_TIME_SPAN_TO_STRING_WITH_CULTURE;HAVE_TIME_ZONE_INFO;HAVE_UNICODE_SURROGATE_DETECTION;HAVE_VARIANT_TYPE_PARAMETERS;HAVE_VERSION_TRY_PARSE;HAVE_XLINQ;HAVE_XML_DOCUMENT;HAVE_CONCURRENT_DICTIONARY;HAVE_ICONVERTIBLE;HAVE_XML_DOCUMENT_TYPE;$(AdditionalConstants)</DefineConstants>
72+
</PropertyGroup>
6773
<PropertyGroup Condition="'$(TargetFramework)' == '$(TargetFrameworkNetStandard)'">
6874
<!-- These are for MSAL json/* build infra -->
6975
<!-- UNITY flag based on https://github.com/jilleJr/Newtonsoft.Json-for-Unity -->
@@ -151,6 +157,12 @@
151157
<Compile Include="$(PathToMsalSources)\PlatformsCommon\PlatformNotSupported\ApiConfig\SystemWebViewOptions.cs" />
152158
<PackageReference Update="System.Security.SecureString" />
153159
</ItemGroup>
160+
<ItemGroup Condition="'$(TargetFramework)' == '$(TargetFrameworkNetMacCatalyst)'">
161+
<!-- Mac Catalyst uses UIKit like iOS, so we reuse the iOS platform code -->
162+
<Compile Include="$(PathToMsalSources)\Platforms\iOS\**\*.cs" />
163+
<Compile Include="$(PathToMsalSources)\PlatformsCommon\PlatformNotSupported\ApiConfig\SystemWebViewOptions.cs" />
164+
<PackageReference Update="System.Security.SecureString" />
165+
</ItemGroup>
154166

155167
<ItemGroup>
156168
<PackageReference Include="Microsoft.IdentityModel.Abstractions" />

src/client/Microsoft.Identity.Client/Platforms/iOS/iOSPlatformProxy.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,11 @@ public override string GetDefaultRedirectUri(string clientId, bool useRecommende
5454

5555
protected override string InternalGetProductName()
5656
{
57+
#if MACCATALYST
58+
return "MSAL.MacCatalyst";
59+
#else
5760
return "MSAL.Xamarin.iOS";
61+
#endif
5862
}
5963

6064
/// <summary>

0 commit comments

Comments
 (0)