This issue still persists in the latest 18.0 beta.
Post
Replies
Boosts
Views
Activity
this project is using CloudKit for persistence through SwiftData...
In order to use CloudKit's sharing APIs, such as CKShare.Participant, which contains the info you'd like to access, you'd need to implement a coexistence approach with Core Data and SwiftData. In iOS 17 SwiftData can express only a subset of NSPersistentCloudKitContainer's capabilities, and CloudKit sharing isn't one of them.
That said, does your app have a use for CloudKit sharing? If not, and if your app is for macOS, you could use NSFullUserName().
In the event someone is using CloudKit sharing and needs to access the current user's name components, I found that using a CKShare directly works in iOS 17:
func fetchCurrentUsername(for share: CKShare) -> String {
var name = ""
let currentUser = share.currentUserParticipant
if let nameComponents = currentUser?.userIdentity.nameComponents {
name = nameComponents.formatted()
}
return name
}