-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
Description
I created a new MAUI Class Library with platform dependent files and folders. Now from a file with an *.iOS.cs extension which should only be compiled for iOS and MacCatalyst I want to call a method in a file in Platforms/iOS/iOSHelper.cs which should also only be compiled for iOS and MacCatalyst. But I get an error that the Platforms.iOS namespace does not exist. It looks like VS tries to compile my .iOS.cs file for net6 and for that TargetFramework it really does not exist.
But the project dropdown only shows iOS and MacCatalyst as expected.
The same as the class I want to call.
The funny thing is, that VS does not show an error in intellisense. It even added the using statement itself (added with ctrl-.).
I also have similar code in LabelHandler.Android.cs where I call into MauiLib2.Platforms.Android.AndroidHelper and this works.
Here is a repro project:
MauiLib2.zip
Steps to Reproduce
- open VS Version 17.2.0 Preview 5.0
- create a new MAUI Class Library
- copy the lines from https://docs.microsoft.com/en-us/dotnet/maui/platform-integration/configure-multi-targeting#combine-filename-and-folder-multi-targeting to the .csproj file
- create a class with an .iOS.cs extension outside the Platforms folder
- create another class in Platforms/iOS
- try to call the latter from the former
(or simply open the attached repro project and try to compile it)
Version with bug
Release Candidate 2 (current)
Last version that worked well
Unknown/Other
Affected platforms
Windows
Affected platform versions
Visual Studio Version 17.2.0 Preview 5.0
Did you find any workaround?
No
Relevant log output
The error message in the Output window is:
1>D:\Temp\MauiLib2\MauiLib2\Handlers\LabelHandler.iOS.cs(3,16,3,25): error CS0234: The type or namespace name 'Platforms' does not exist in the namespace 'MauiLib2' (are you missing an assembly reference?)
But the Error List shows it better as this includes the platform for which it tries to compile.

