Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GameKit] Add support for Xcode 15 #19285

Merged
merged 14 commits into from
Oct 31, 2023
58 changes: 49 additions & 9 deletions src/gamekit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,12 @@ namespace GameKit {
delegate void GKImageLoadedHandler (NSImage image, NSError error);
delegate void GKPlayerPhotoLoaded (NSImage photo, NSError error);
delegate void GKChallengeComposeHandler (NSViewController composeController, bool issuedChallenge, string [] sentPlayerIDs);
delegate void GKChallengeComposeHandler2 (NSViewController composeController, bool issuedChallenge, GKPlayer[] sentPlayers);
#else
delegate void GKImageLoadedHandler (UIImage image, NSError error);
delegate void GKPlayerPhotoLoaded (UIImage photo, NSError error);
delegate void GKChallengeComposeHandler (UIViewController composeController, bool issuedChallenge, string [] sentPlayerIDs);
delegate void GKChallengeComposeHandler2 (UIViewController composeController, bool issuedChallenge, [NullAllowed] GKPlayer [] sentPlayers);
#endif

#if WATCH
Expand Down Expand Up @@ -526,9 +528,10 @@ interface GKLeaderboardSet : NSCoding, NSSecureCoding {
[MacCatalyst (13, 1)]
[BaseType (typeof (NSObject))]
interface GKBasePlayer {
[Deprecated (PlatformName.iOS, 16, 0, message: "Use the GKPlayer.TeamPlayerId property to identify a player instead.")]
[Deprecated (PlatformName.TvOS, 16, 0, message: "Use the GKPlayer.TeamPlayerId property to identify a player instead.")]
[Deprecated (PlatformName.MacCatalyst, 16, 0, message: "Use the GKPlayer.TeamPlayerId property to identify a player instead.")]
[Deprecated (PlatformName.iOS, 13, 0, message: "Use the GKPlayer.TeamPlayerId property to identify a player instead.")]
[Deprecated (PlatformName.TvOS, 13, 0, message: "Use the GKPlayer.TeamPlayerId property to identify a player instead.")]
[Deprecated (PlatformName.WatchOS, 6, 0, message: "Use the GKPlayer.TeamPlayerId property to identify a player instead.")]
[Deprecated (PlatformName.MacCatalyst, 13, 1, message: "Use the GKPlayer.TeamPlayerId property to identify a player instead.")]
[Deprecated (PlatformName.MacOSX, 10, 15, message: "Use the GKPlayer.TeamPlayerId property to identify a player instead.")]
[NullAllowed, Export ("playerID", ArgumentSemantic.Retain)]
string PlayerID { get; }
Expand Down Expand Up @@ -1267,6 +1270,10 @@ interface GKVoiceChat {
[MacCatalyst (13, 1)]
[Export ("setPlayer:muted:")]
void SetMuteStatus (GKPlayer player, bool isMuted);

[MacCatalyst (13, 1)]
[Export ("playerVoiceChatStateDidChangeHandler", ArgumentSemantic.Copy)]
Action<GKPlayer, GKVoiceChatPlayerState> PlayerVoiceChatStateDidChangeHandler { get; }
}

[MacCatalyst (13, 1)]
Expand Down Expand Up @@ -1560,13 +1567,13 @@ interface GKMatchmakerViewControllerDelegate {
[Export ("matchmakerViewController:didFailWithError:"), EventArgs ("GKError")]
void DidFailWithError (GKMatchmakerViewController viewController, NSError error);

#if !NET
#if !NET && !XAMCORE_5_0
[Abstract]
#endif
[Export ("matchmakerViewController:didFindMatch:"), EventArgs ("GKMatch")]
void DidFindMatch (GKMatchmakerViewController viewController, GKMatch match);

#if !NET
#if !NET && !XAMCORE_5_0
[Abstract]
#endif
[NoTV]
Expand All @@ -1577,7 +1584,7 @@ interface GKMatchmakerViewControllerDelegate {
[Export ("matchmakerViewController:didFindPlayers:"), EventArgs ("GKPlayers")]
void DidFindPlayers (GKMatchmakerViewController viewController, string [] playerIDs);

#if !NET
#if !NET && !XAMCORE_5_0
[Abstract]
#endif
[MacCatalyst (13, 1)]
Expand Down Expand Up @@ -1712,9 +1719,18 @@ string PlayerID {
[NoWatch]
[MacCatalyst (13, 1)]
[Async (ResultTypeName = "GKChallengeComposeResult")]
[Deprecated (PlatformName.iOS, 17, 0)]
[Deprecated (PlatformName.MacOSX, 14, 0)]
[Deprecated (PlatformName.TvOS, 17, 0)]
[Deprecated (PlatformName.MacCatalyst, 17, 0)]
[Export ("challengeComposeControllerWithMessage:players:completionHandler:")]
UIViewController ChallengeComposeController ([NullAllowed] string message, GKPlayer [] players, [NullAllowed] GKChallengeComposeHandler completionHandler);

[TV (17, 0), iOS (17, 0), Mac (14, 0), MacCatalyst (17, 0), NoWatch]
[Export ("challengeComposeControllerWithMessage:players:completion:")]
[Async (ResultTypeName = "GKChallengeComposeControllerResult")]
UIViewController ChallengeComposeControllerWithMessage ([NullAllowed] string message, GKPlayer [] players, [NullAllowed] GKChallengeComposeHandler2 completionHandler);

[NoWatch]
[MacCatalyst (13, 1)]
[Async]
Expand Down Expand Up @@ -1798,6 +1814,11 @@ interface GKAchievementDescription : NSSecureCoding {
[Static]
[Export ("placeholderCompletedAchievementImage")]
UIImage PlaceholderCompletedAchievementImage { get; }

[Watch (10, 0), TV (17, 0), Mac (14, 0), iOS (17, 0), MacCatalyst (17, 0)]
[Export ("rarityPercent", ArgumentSemantic.Copy)]
[NullAllowed]
NSNumber RarityPercent { get; }
}

[NoWatch]
Expand Down Expand Up @@ -1927,6 +1948,10 @@ interface GKFriendRequestComposeViewControllerDelegate {

[NoWatch]
[MacCatalyst (13, 1)]
[Deprecated (PlatformName.iOS, 17, 0, message: "Use UNNotificationRequest or provide custom UI instead. This method will become a no-op in a future version of GameKit.")]
[Deprecated (PlatformName.MacOSX, 14, 0, message: "Use UNNotificationRequest or provide custom UI instead. This method will become a no-op in a future version of GameKit.")]
[Deprecated (PlatformName.TvOS, 16, 1, message: "Use UNNotificationRequest or provide custom UI instead. This method will become a no-op in a future version of GameKit.")]
[Deprecated (PlatformName.MacCatalyst, 17, 0, message: "Use UNNotificationRequest or provide custom UI instead. This method will become a no-op in a future version of GameKit.")]
[BaseType (typeof (NSObject))]
partial interface GKNotificationBanner {
[Static, Export ("showBannerWithTitle:message:completionHandler:")]
Expand Down Expand Up @@ -1998,7 +2023,7 @@ interface GKTurnBasedEventHandlerDelegate {
[Export ("handleMatchEnded:")]
void HandleMatchEnded (GKTurnBasedMatch match);

#if !MONOMAC || NET
#if !MONOMAC || NET || XAMCORE_5_0
[Abstract]
#endif
[Export ("handleTurnEventForMatch:didBecomeActive:")]
Expand Down Expand Up @@ -2252,15 +2277,19 @@ interface GKTurnBasedMatchmakerViewController : UIAppearance
[Model]
[Protocol]
interface GKTurnBasedMatchmakerViewControllerDelegate {
#if !XAMCORE_5_0
[Abstract]
#endif
[Export ("turnBasedMatchmakerViewControllerWasCancelled:")]
void WasCancelled (GKTurnBasedMatchmakerViewController viewController);

#if !XAMCORE_5_0
[Abstract]
#endif
[Export ("turnBasedMatchmakerViewController:didFailWithError:")]
void FailedWithError (GKTurnBasedMatchmakerViewController viewController, NSError error);

#if !NET
#if !NET && !XAMCORE_5_0
[Abstract]
#endif
[NoTV]
Expand All @@ -2271,7 +2300,7 @@ interface GKTurnBasedMatchmakerViewControllerDelegate {
[Export ("turnBasedMatchmakerViewController:didFindMatch:")]
void FoundMatch (GKTurnBasedMatchmakerViewController viewController, GKTurnBasedMatch match);

#if !NET
#if !NET && !XAMCORE_5_0
[Abstract]
#endif
[NoTV]
Expand Down Expand Up @@ -2647,6 +2676,7 @@ interface GKTurnBasedEventListener {
[Deprecated (PlatformName.iOS, 8, 0, message: "Use 'DidRequestMatchWithOtherPlayers' instead.")]
[MacCatalyst (13, 1)]
[Deprecated (PlatformName.MacCatalyst, 13, 1, message: "Use 'DidRequestMatchWithOtherPlayers' instead.")]
[Deprecated (PlatformName.MacOSX, 10, 0, message: "Use 'DidRequestMatchWithOtherPlayers' instead.")]
[Export ("player:didRequestMatchWithPlayers:")]
void DidRequestMatchWithPlayers (GKPlayer player, string [] playerIDsToInvite);

Expand Down Expand Up @@ -2964,11 +2994,21 @@ interface GKLeaderboardEntry {
[Export ("date", ArgumentSemantic.Strong)]
NSDate Date { get; }
#endif

[NoWatch] // header lists watch as supported, but UIViewController is not available on Watch!
[MacCatalyst (13, 1)]
[Async (ResultTypeName = "GKChallengeComposeResult")]
[Deprecated (PlatformName.iOS, 17, 0)]
[Deprecated (PlatformName.TvOS, 17, 0)]
[Deprecated (PlatformName.MacCatalyst, 17, 0)]
[Deprecated (PlatformName.MacOSX, 14, 0)]
[Export ("challengeComposeControllerWithMessage:players:completionHandler:")]
UIViewController ChallengeComposeController ([NullAllowed] string message, [NullAllowed] GKPlayer [] players, [NullAllowed] GKChallengeComposeHandler completionHandler);

[TV (17, 0), iOS (17, 0), MacCatalyst (17, 0), Mac (14, 0), NoWatch]
[Export ("challengeComposeControllerWithMessage:players:completion:")]
[Async (ResultTypeName = "GKChallengeComposeControllerResult")]
UIViewController ChallengeComposeControllerWithMessage ([NullAllowed] string message, [NullAllowed] GKPlayer [] players, [NullAllowed] GKChallengeComposeHandler2 completionHandler);
}

[Watch (7, 0), TV (14, 0), Mac (11, 0), iOS (14, 0)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
## All GKSessionError values were deprecated in iOS7 and we never bound then (no point in adding it now)
!missing-field! GKSessionErrorDomain not bound

## enum size declared after the enum, e.g. `typedef NSInteger GKInviteeResponse;`, so we miss the metadata
!unknown-native-enum! GKInviteeResponse bound

# Xcode 12 beta 3 - these API are missing
# https://github.com/xamarin/maccore/issues/2269
!missing-selector! GKLeaderboardEntry::context not bound
!missing-selector! GKLeaderboardEntry::date not bound
!missing-selector! GKLeaderboardEntry::formattedScore not bound
!missing-selector! GKLeaderboardEntry::rank not bound
!missing-selector! GKLeaderboardEntry::score not bound

## unsorted

Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
# API removed by Apple, marked as deprecated
13 changes: 0 additions & 13 deletions tests/xtro-sharpie/api-annotations-dotnet/iOS-GameKit.todo

This file was deleted.

12 changes: 12 additions & 0 deletions tests/xtro-sharpie/api-annotations-dotnet/macOS-GameKit.ignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,15 @@
# nor the below protocols

# This selector does not exist in macOS, confirmed by intro.

# Deprecated
!missing-protocol-member! GKInviteEventListener::player:didRequestMatchWithPlayers: not found
!missing-protocol-member! GKTurnBasedEventListener::player:didRequestMatchWithPlayers: not found

# We have bound GKVoiceChatServiceError as GKVoiceChatServiceError which has no support for macOS
!missing-field! GKVoiceChatServiceErrorDomain not bound
# https://developer.apple.com/documentation/gamekit/gkvoicechatserviceerror?language=objc

# This selector does not exist (respond?) in macOS either
!missing-selector! GKLeaderboardSet::loadImageWithCompletionHandler: not bound

14 changes: 0 additions & 14 deletions tests/xtro-sharpie/api-annotations-dotnet/macOS-GameKit.todo

This file was deleted.

7 changes: 0 additions & 7 deletions tests/xtro-sharpie/api-annotations-dotnet/tvOS-GameKit.ignore
Original file line number Diff line number Diff line change
@@ -1,7 +0,0 @@
!missing-field! GKSessionErrorDomain not bound
!missing-selector! GKLeaderboardEntry::context not bound
!missing-selector! GKLeaderboardEntry::date not bound
!missing-selector! GKLeaderboardEntry::formattedScore not bound
!missing-selector! GKLeaderboardEntry::rank not bound
!missing-selector! GKLeaderboardEntry::score not bound
!missing-selector! GKVoiceChat::playerVoiceChatStateDidChangeHandler not bound
6 changes: 0 additions & 6 deletions tests/xtro-sharpie/api-annotations-dotnet/tvOS-GameKit.todo

This file was deleted.

7 changes: 6 additions & 1 deletion tests/xtro-sharpie/common-GameKit.ignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
## All GKSessionError values were deprecated in iOS7 and we never bound then (no point in adding it now)
!missing-field! GKSessionErrorDomain not bound
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also not binding GKSessionErrorDomain due to this


## enum size declared after the enum, e.g. `typedef NSInteger GKInviteeResponse;`, so we miss the metadata
!unknown-native-enum! GKInviteeResponse bound

# Xcode 12 beta 3 - these API are missing
# https://github.com/xamarin/maccore/issues/2269
!missing-selector! GKLeaderboardEntry::context not bound
!missing-selector! GKLeaderboardEntry::date not bound
!missing-selector! GKLeaderboardEntry::formattedScore not bound
!missing-selector! GKLeaderboardEntry::rank not bound
!missing-selector! GKLeaderboardEntry::score not bound

## unsorted
12 changes: 8 additions & 4 deletions tests/xtro-sharpie/iOS-GameKit.ignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# fixed in XAMCORE_3_0 - API break


# API removed by Apple, marked as deprecated
!unknown-native-enum! GKAuthenticationType bound

# Xcode1 4 beta 4

# addressed in XAMCORE_5_0

!incorrect-protocol-member! GKMatchmakerViewControllerDelegate::matchmakerViewController:didFindHostedPlayers: is OPTIONAL and should NOT be abstract
!incorrect-protocol-member! GKMatchmakerViewControllerDelegate::matchmakerViewController:didFindMatch: is OPTIONAL and should NOT be abstract
!incorrect-protocol-member! GKMatchmakerViewControllerDelegate::matchmakerViewController:didFindPlayers: is OPTIONAL and should NOT be abstract
!incorrect-protocol-member! GKTurnBasedMatchmakerViewControllerDelegate::turnBasedMatchmakerViewController:didFindMatch: is OPTIONAL and should NOT be abstract
!incorrect-protocol-member! GKTurnBasedMatchmakerViewControllerDelegate::turnBasedMatchmakerViewController:playerQuitForMatch: is OPTIONAL and should NOT be abstract
19 changes: 0 additions & 19 deletions tests/xtro-sharpie/iOS-GameKit.todo

This file was deleted.

22 changes: 22 additions & 0 deletions tests/xtro-sharpie/macOS-GameKit.ignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,25 @@

# API removed by Apple, marked as deprecated
!unknown-native-enum! GKAuthenticationType bound

# Deprecated
!missing-protocol-member! GKInviteEventListener::player:didRequestMatchWithPlayers: not found

# We have bound GKVoiceChatServiceError as GKVoiceChatServiceError which has no support for macOS
!missing-field! GKVoiceChatServiceErrorDomain not bound
# https://developer.apple.com/documentation/gamekit/gkvoicechatserviceerror?language=objc

# addressed in XAMCORE_5_0
!incorrect-protocol-member! GKTurnBasedEventHandlerDelegate::handleTurnEventForMatch:didBecomeActive: is REQUIRED and should be abstract

# This selector does not exist (respond?) in macOS either
!missing-selector! GKLeaderboardSet::loadImageWithCompletionHandler: not bound

# is marked as Obsolete
!extra-protocol-member! unexpected selector GKMatchDelegate::xamarin:selector:removed: found

!incorrect-protocol-member! GKMatchmakerViewControllerDelegate::matchmakerViewController:didFindHostedPlayers: is OPTIONAL and should NOT be abstract
!incorrect-protocol-member! GKMatchmakerViewControllerDelegate::matchmakerViewController:didFindMatch: is OPTIONAL and should NOT be abstract
!incorrect-protocol-member! GKMatchmakerViewControllerDelegate::matchmakerViewController:didFindPlayers: is OPTIONAL and should NOT be abstract
!incorrect-protocol-member! GKTurnBasedMatchmakerViewControllerDelegate::turnBasedMatchmakerViewController:didFindMatch: is OPTIONAL and should NOT be abstract
!incorrect-protocol-member! GKTurnBasedMatchmakerViewControllerDelegate::turnBasedMatchmakerViewController:playerQuitForMatch: is OPTIONAL and should NOT be abstract
Loading