This is a Swift package with support for iOS that allows to use GameKit with UIKit and SwiftUI.

Enable players to interact with friends, compare leaderboard ranks and earn achievements.


The latest version of GameKitUI requires:

- Swift 5+
- iOS 14+
- Xcode 13+


Swift Package Manager

Using SPM add the following to your dependencies

‘GameCenterKit’, ‘main’, ‘

How to use?


1. The local player must be authenticated on Game Center
2. Your app need an identifier leaderboard defined in App Store Connect.

First the local player must be authenticated on Game Center.

Authenticates the local player with in Game Center if it’s possible.


To presents the Game Center view provided by GameKit there are 3 options:

1. Toggle AccessPointView
2. Open from a ViewController (UIKit)
3. Open from a View (SwiftUI)

Toggle AccessPointView


Open from a ViewController (UIKit)

do {
    try GameCenterKit.shared.showGameCenter(viewController: self)
} catch {

Open from a View (SwiftUI)

import SwiftUI
import GameCenterKit

struct ContentView: View {
    @State var isGameCenterOpen: Bool = false
    var body: some View {
        VStack {
            Button {
                isGameCenterOpen = true
            } label: {
                Text("Open GameCenter View")
                    .padding(.all, 5.0)
        .sheet(isPresented: $isGameCenterOpen) {

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {

Leaderboards actions

let identifierId: String = "your-app-leaderboard-id"

Retrieve Score

The score earned by the local player (time scope defined is all time).

let bestScore: Int = 0

if let score = try await GameCenterKit.shared.retrieveScore(identifier: identifierId) {
    print("best score: \(String(describing: score))")
    self.bestScore = score

Retrieve Rank

The rank earned by the local player (time scope defined is all time).

do {
    let (current, previous) = try await GameCenterKit.shared.retrieveRank(identifier: identifierId)
    print("current rank: \(String(describing: current))")
    print("previous rank: \(String(describing: previous))")
} catch {

Retrieve Best Players

The best players list and the number of total players (time scope defined is all time).

// Number of top players (1 - 50) to use for getting the scores.
let topPlayers: Int = 10     

do {
   let (players, totalPlayers) = try await GameCenterKit.shared.retrieveBestPlayers(identifier: identifierId, topPlayers: topPlayers)
   print("total players: \(String(describing: totalPlayers))")
   for player in players {
       print("player: \(player.displayName)\t score: \(player.leaderboard.score)")
} catch {

Submit Score

Reports a high score eligible for placement on a leaderboard.

// The score earned by the local player
let score: Int = 10

do {
    try await GameCenterKit.shared.submitScore(score: score, identifier: identifierId)
} catch {

Achievements actions

let achievementId: String = "your-app-achievement-id"

Submit Achievement

Reports progress on an achievement, if it has not been completed already.

// A percentage value (0 - 100) stating how far the user has progressed on the achievement
let percent: Double = 10.0

do {
    try await GameCenterKit.shared.submitAchievement(identifier: achievementId, percent: percent)
} catch {

Reset Achievements

Resets the percentage completed for all of the player’s achievements.

do {
    try await GameCenterKit.shared.resetAchievements()
} catch {



View Github