Hello,
You could open the CustomShellRenderer.cs
file and see if the namespace is Test1.Platforms.iOS
, and then add the condition on MauiProgram.cs
.
#if IOS
using Test1.Platforms.iOS;// the namespace may be this
#endif
If you still have the problem, you could configure filename-based multi-targeting, see Configure .NET MAUI multi-targeting - .NET MAUI | Microsoft Learn
For example:
<!-- iOS -->
<ItemGroup Condition="$(TargetFramework.StartsWith('net8.0-ios')) != true">
<Compile Remove="**\*.iOS.cs" />
<None Include="**\*.iOS.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
</ItemGroup>
There is also another way, you could remove the CustomShellRenderer.cs
in the Plattforms/iOS
folder, and then add the condition, copy the code on MauiProgram.cs
directly.
For example:
#if IOS
public class CustomShellRenderer : ShellRenderer
{
...// your code
}
public class CustomSectionRenderer : ShellSectionRenderer
{
...
}
#endif
Best Regards,
Wenyan Zhang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.