-
I don't know whether this is a bug so I thought to open it first as a discussion. I've created a MAUI application that has a referenced to a MAUI binding project with a native library but when I'm building the solution it fails with the following error:
Some details about my setup:
This is the xcode project file
This is the C# project file <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0-maccatalyst</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>true</ImplicitUsings>
<IsBindingProject>true</IsBindingProject>
</PropertyGroup>
<ItemGroup>
<ObjcBindingApiDefinition Include="ApiDefinition.cs"/>
<ObjcBindingCoreSource Include="StructsAndEnums.cs"/>
</ItemGroup>
<ItemGroup>
<NativeReference Include="$(SolutionDir)../libs/libCatalystShellExtension.a">
<Kind>Static</Kind>
<ForceLoad>True</ForceLoad>
<SmartLink>False</SmartLink>
</NativeReference>
</ItemGroup>
</Project> This is the MAUI project file <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0-maccatalyst</TargetFramework>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.0-windows10.0.19041.0</TargetFrameworks>
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
<!-- <TargetFrameworks>$(TargetFrameworks);net8.0-tizen</TargetFrameworks> -->
<!-- Note for MacCatalyst:
The default runtime is maccatalyst-x64, except in Release config, in which case the default is maccatalyst-x64;maccatalyst-arm64.
When specifying both architectures, use the plural <RuntimeIdentifiers> instead of the singular <RuntimeIdentifier>.
The Mac App Store will NOT accept apps with ONLY maccatalyst-arm64 indicated;
either BOTH runtimes must be indicated or ONLY macatalyst-x64. -->
<!-- For example: <RuntimeIdentifiers>maccatalyst-x64;maccatalyst-arm64</RuntimeIdentifiers> -->
<OutputType>Exe</OutputType>
<RootNamespace>WowSync</RootNamespace>
<UseMaui>true</UseMaui>
<SingleProject>true</SingleProject>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<!-- Display name -->
<ApplicationTitle>WowSync</ApplicationTitle>
<!-- App Identifier -->
<ApplicationId>com.eyalalon.WowSync</ApplicationId>
<!-- Versions -->
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
<ApplicationVersion>1</ApplicationVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">14.2</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
</PropertyGroup>
<ItemGroup>
<!-- App Icon -->
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4"/>
<!-- Splash Screen -->
<MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128"/>
<!-- Images -->
<MauiImage Include="Resources\Images\*"/>
<MauiImage Update="Resources\Images\dotnet_bot.png" Resize="True" BaseSize="300,185"/>
<!-- Custom Fonts -->
<MauiFont Include="Resources\Fonts\*"/>
<!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)"/>
</ItemGroup>
<ItemGroup>
<PackageReference Include="CommunityToolkit.Maui" Version="7.0.1" />
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)"/>
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="$(MauiVersion)"/>
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0"/>
</ItemGroup>
<ItemGroup>
<MauiXaml Update="Views\MainPage.xaml">
<SubType>Designer</SubType>
</MauiXaml>
</ItemGroup>
<ItemGroup>
<Compile Update="Views\MainPage.xaml.cs">
<DependentUpon>MainPage.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CatalystShellBindings\CatalystShellBindings.csproj" />
</ItemGroup>
</Project> The xcode project and the bindings project build just fine on their own but when I reference the bindings library to the MAUI application (without calling anything at all) when building either through Rider or the CLI it fails with the error above. I've been searching but many if not all of the results are about MAUI and iOS/Android/Windows or Xamarin but they are outdated, unfortunately, I couldn't find a complete example that show how to create a native library on xcode with the correct settings that targets macOS (arm64) Catalyst, a binding library for MAUI on .NET 8 and an application that consumes it. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Well, to solve this you actually have to set the base SDK in Xcode to iOS as opposed to macOS then from the Xcode's Toolbar you can select Mac Catalyst but then my project wouldn't compile now because Mac Catalyst uses UIKit as opposed to AppKit but that's another issue. |
Beta Was this translation helpful? Give feedback.
Well, to solve this you actually have to set the base SDK in Xcode to iOS as opposed to macOS then from the Xcode's Toolbar you can select Mac Catalyst but then my project wouldn't compile now because Mac Catalyst uses UIKit as opposed to AppKit but that's another issue.