Contacts API namespace conflicts on MacCatalyst and iOS
See original GitHub issueDescription
I just upgraded to VS 17.3 P1.1 and the essentials API is complaining that the Contacts
type in the Microsoft.Maui.ApplicationModel.Communication
namespace is missing. Digging further it seems that there is a conflict with the type because there is a root namespace of Contacts
already imported.
Generic code for .NET MAUI that should compile across all platforms won’t compile for iOS or MacCatalyst without #if or always fully qualifying the type.
Steps to Reproduce
Code that contains the following line should work on all platforms. It won’t compile on iOS/MacCatalyst
var contact = await Contacts.Default.PickContactAsync();
Version with bug
Release Candidate 3 (current)
Last version that worked well
Release Candidate 2
Affected platforms
iOS, macOS
Affected platform versions
Unsure
Did you find any workaround?
You have to fully qualify the name:
var contact = await Microsoft.Maui.ApplicationModel.Communication.Contacts.Default.PickContactAsync();
Relevant log output
CS0234 The type or namespace name 'Default' does not exist in the namespace 'Contacts' (are you missing an assembly reference?) PlatformIntegration (net6.0-ios), PlatformIntegration (net6.0-maccatalyst)
Issue Analytics
- State:
- Created a year ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Contacts - .NET MAUI
Because of a namespace conflict, the Contacts type must be fully qualified when targeting iOS or macOS: Microsoft.Maui.ApplicationModel.
Read more >WKContentWorld | Apple Developer Documentation
A WKContentWorld object is a namespace and doesn't persist data outside of the current web view or webpage. If you use the same...
Read more >The type or namespace name 'Platforms' does not exist in ...
When I read the entire error message, it states that it can't resolve the name in the iOS, Windows, MacCatalyst and Tizen projects....
Read more >Avoiding property/method naming conflicts in Swift
Namespaces are used so we can group related methods and properties and avoid naming conflicts between multiple identifiers which may share the same...
Read more >Apple Seeds Fifth Betas of iOS 17 and iPadOS 17 to ...
Apple today seeded the fifth betas of upcoming iOS 17 and iPadOS 17 updates to developers for testing purposes, with the software coming...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Eilon I’m finding that if iOS or Mac is a target, you must always fully qualify the type, or you can’t compile for all platforms. And these are targeted by default, obviously.
When I ran into this issue, I tried what you suggested, mapping
Contacts
specifically, this didn’t work thoughThe only way this works is by mapping the namespace instead:
@Eilon it seems to be something with mac/ios directly. There is a root namespace automatically imported when you target that framework. Here is the output of the intellisense and browsing to the code of one of those items: