I am currently working on a Swift/SwiftUI game with GameCenter / Gamekit integration.
I have successfully integrated game kit for leaderboards/scores, but I am having issues with achievements.
At the moment I am not sure if the problem lies with the testing procedure or with the code itself.
Just for background:
- App is currently published in the app store with a live leaderboard
- App version that is published does not have any achievements
- I have added achievements to the AppStoreConnect section
if self.parent.levelCount == 5 {
print("I Entered Level 5")
let achievement = GKAchievement.init(identifier: "level5", player: GKLocalPlayer.local)
achievement.percentComplete = 100
achievement.showsCompletionBanner = true
GKAchievement.report([achievement]) { (error) in
print(error?.localizedDescription ?? "")
}
}
The above code runs, it enters the loop once the user reaches level 5, I get no errors, but I am unable to see the achievements once I enter gamecenter.
Is there something I need to change in the testing procedure in order to see achievements before publishing a new version of the app?
Or am I doing something wrong with the implementation of the code?
Any help is greatly appreciated, Daniel