Replies: 1 comment
-
I also wanted to use folder based multi-targeting to avoid duplicated code between iOS and MacCatalyst. As you've linked above, the documentation shows how to configure this situation. However, for "Single Project" builds, MAUI has default rules that apply to the "Platforms" directory: Microsoft.Maui.Controls.SingleProject.targets It's included after your project, and will override whatever is in your project file. So, it works for other directories (e.g. "Platforms2/MaciOS" but not "Platforms/MaciOS"). Or you could perhaps do something like the opposite, by moving the MAUI handled "Platforms" directory out of the way, which would allow the custom rules from the documentation to take effect:
|
Beta Was this translation helpful? Give feedback.
-
Let's say I have a partial class that defines an "initialize" method on each platform, and I call that method from my shared codebase.
I defined that partial class on Android and Windows platform.
But both the Mac & iOS implementations, have the same code. So I wouldn't like to define it twice on Mac and iOS platform folders.
I followed this guide: https://github.com/dotnet/docs-maui/blob/main/docs/platform-integration/configure-multi-targeting.md
Applied "folder-based multi-targeting" and created a "MaciOS" platform folder, to define the class there.
Problem is my shared codebase says there is no implementation on iOS and Mac platforms. It makes sense, because iOS and Mac folders are empty, but MaciOS folder has the class.
Even my "MaciOS" folder's class, has no intellisense and Visual Studio doesn't say I'm on iOS or Mac platform, but it says "Miscellaneous Files".
I think the problem is I'm missing some "SupportedOSPlatformVersion" on my .csproject
Because I don't have an option for both "iOS and Mac", but I have the stock ones:
How can I get both platforms there? or any workaround to share Mac & iOS code without using conditional compilation and without repeating code.
Beta Was this translation helpful? Give feedback.
All reactions