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
64 changes: 51 additions & 13 deletions src/gamekit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -526,9 +526,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 +1268,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 +1565,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 +1582,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 @@ -1709,10 +1714,19 @@ string PlayerID {
[Export ("initWithIdentifier:player:")]
NativeHandle Constructor ([NullAllowed] string identifier, GKPlayer player);

[NoWatch]
#if XAMCORE_5_0
[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:")]
#else
[TV (17, 0), iOS (17, 0), Mac (14, 0), MacCatalyst (17, 0)]
[Export ("challengeComposeControllerWithMessage:players:completion:")]
#endif
[NoWatch]
[Async (ResultTypeName = "GKChallengeComposeResult")]
haritha-mohan marked this conversation as resolved.
Show resolved Hide resolved
UIViewController ChallengeComposeController ([NullAllowed] string message, GKPlayer [] players, [NullAllowed] GKChallengeComposeHandler completionHandler);

[NoWatch]
Expand Down Expand Up @@ -1798,6 +1812,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 +1946,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 +2021,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 +2275,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 +2298,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 +2674,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,10 +2992,20 @@ interface GKLeaderboardEntry {
[Export ("date", ArgumentSemantic.Strong)]
NSDate Date { get; }
#endif
[NoWatch] // header lists watch as supported, but UIViewController is not available on Watch!

#if XAMCORE_5_0
[TV(17, 0), iOS(17, 0), MacCatalyst(17, 0), Mac(14,0)]
[Export("challengeComposeControllerWithMessage:players:completion:")]
Copy link
Member

Choose a reason for hiding this comment

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

This needs to be bound as a new method, not replace an existing one in the future, because they have different signatures (the callbacks are different).

#else
[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:")]
#endif
[NoWatch] // header lists watch as supported, but UIViewController is not available on Watch!
[Async (ResultTypeName = "GKChallengeComposeResult")]
UIViewController ChallengeComposeController ([NullAllowed] string message, [NullAllowed] GKPlayer [] players, [NullAllowed] GKChallengeComposeHandler completionHandler);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,10 @@

## unsorted

!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
Copy link
Member

Choose a reason for hiding this comment

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

Why are these ignored? Looks like they can be 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.

@mandel-macaque tried binding them but still get similar intro failures as the ones mentioned here https://github.com/xamarin/maccore/issues/2269

as discussed in the thread, the GKLeaderboardEntry cannot be directly init, so i can try to figure out how to test them out somehow


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

# addressed in XAMCORE_5_0
!missing-selector! GKLeaderboardEntry::challengeComposeControllerWithMessage:players:completion: not bound

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

This file was deleted.

15 changes: 15 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,18 @@
# 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

# addressed in XAMCORE_5_0
!missing-selector! GKLeaderboardEntry::challengeComposeControllerWithMessage:players:completion: not bound

# 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.

10 changes: 3 additions & 7 deletions tests/xtro-sharpie/api-annotations-dotnet/tvOS-GameKit.ignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
!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
# addressed in XAMCORE_5_0
!missing-selector! GKLeaderboardEntry::challengeComposeControllerWithMessage:players:completion: not bound

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

This file was deleted.

11 changes: 10 additions & 1 deletion tests/xtro-sharpie/common-GameKit.ignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,14 @@

# 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

# we have bound this enum as GKErrorDomain instead
!missing-field! GKSessionErrorDomain not bound

# addressed in XAMCORE_5_0

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


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

# Xcode1 4 beta 4
!missing-selector! GKLeaderboardEntry::challengeComposeControllerWithMessage:players:completion: not bound

# 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.

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

# 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
!missing-selector! GKLeaderboardEntry::challengeComposeControllerWithMessage:players:completion: not bound

# 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
21 changes: 0 additions & 21 deletions tests/xtro-sharpie/macOS-GameKit.todo

This file was deleted.

Loading