How do you issue a challenge to another player in Swift using GameKit?

I've been able to follow some of the limited guides here and on Apple's website to set up a leaderboard and achievements using Game Center / GameKit for Swift (iOS 15). However, I am now stuck in terms of creating player-to-player challenges using Game Center.

I read the post here that made a reference to converting C code to Swift. I've also read through a PDF (not linked since it may be copyrighted) that has a lot of C code. However, I don't know how to convert any of that code to Swift.

I am trying to do the following:

  1. Get a list of Friends that the player can send a challenge to
  2. Invite a friend from that list to take part in a GKScoreChallenge.
  3. Set up a GKScoreChallenge.loadReceivedChallenges() that alerts a player that they have a challenge
  4. Resolve the challenge (either cancel it, or adjudicate it in favor of another player once it is completed)

I don't even have a starting place for this. Extensive Googling gets me to Apple's (terrible) documentation pages. There is a reference to a WWDC 2021 video, but I can't find any sample code to follow along and code this in Swift.

Any help would be appreciated. Even a place to start where I can figure this out would be helpful.

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum