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:
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
After digging a little bit in the Apple developer forums I was able to find other users with the same issue.
In order to test achievements in the development version of the application, you must go to AppStore connect and in a new version of the app toggle the achievements you are testing (you do not need to publish the version).