Skip to content

Commit

Permalink
[CloudKit] Implement Xcode 16.0 beta 1-6 changes. (#20861)
Browse files Browse the repository at this point in the history
The bindings that have been removed haven't fully been removed from the
headers, but it looks like they will be soon. These bindings have also been
deprecated since before the earliest OS versions we support, so there should
be no need to keep them around.

Removing them preemptively also lessens the risk of running into App Store
rejections in the future.

A few tests changes were needed to ignore the newly obsoleted/hidden APIs.

Note: there were no changes in beta 2, beta 3, beta 4, beta 5 or beta 6.
  • Loading branch information
rolfbjarne authored Aug 23, 2024
1 parent 6016b2c commit f3a7879
Show file tree
Hide file tree
Showing 21 changed files with 325 additions and 294 deletions.
9 changes: 0 additions & 9 deletions src/CloudKit/CKCompat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,15 +162,6 @@ public virtual string? LastName {
#endif

#if WATCH

public partial class CKModifyBadgeOperation {

// `init` does not work on watchOS but we can keep compatibility with a different init
public CKModifyBadgeOperation () : this (0)
{
}
}

public partial class CKModifyRecordZonesOperation {

// `init` does not work on watchOS but we can keep compatibility with a different init
Expand Down
97 changes: 97 additions & 0 deletions src/CloudKit/CKFetchNotificationChangesOperation.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#if !XAMCORE_5_0

using System;
using System.ComponentModel;
using System.Runtime.Versioning;
using System.Diagnostics.CodeAnalysis;

using Foundation;
using ObjCRuntime;

#nullable enable

#if !NET
using NativeHandle = System.IntPtr;
#endif

namespace CloudKit {
[Register ("CKFetchNotificationChangesOperation", SkipRegistration = true)]
#if NET
[UnsupportedOSPlatform ("ios", "Use 'CKDatabaseSubscription', 'CKFetchDatabaseChangesOperation' and 'CKFetchRecordZoneChangesOperation' instead.")]
[UnsupportedOSPlatform ("macos", "Use 'CKDatabaseSubscription', 'CKFetchDatabaseChangesOperation' and 'CKFetchRecordZoneChangesOperation' instead.")]
[UnsupportedOSPlatform ("tvos", "Use 'CKDatabaseSubscription', 'CKFetchDatabaseChangesOperation' and 'CKFetchRecordZoneChangesOperation' instead.")]
[UnsupportedOSPlatform ("maccatalyst", "Use 'CKDatabaseSubscription', 'CKFetchDatabaseChangesOperation' and 'CKFetchRecordZoneChangesOperation' instead.")]
#else
[Obsolete ("Use 'CKDatabaseSubscription', 'CKFetchDatabaseChangesOperation' and 'CKFetchRecordZoneChangesOperation' instead.")]
#endif
[EditorBrowsable (EditorBrowsableState.Never)]
public unsafe partial class CKFetchNotificationChangesOperation : CKOperation {
public override NativeHandle ClassHandle { get => throw new PlatformNotSupportedException (Constants.TypeRemovedAllPlatforms); }

protected CKFetchNotificationChangesOperation (NSObjectFlag t) : base (t)
{
throw new PlatformNotSupportedException (Constants.TypeRemovedAllPlatforms);
}

protected internal CKFetchNotificationChangesOperation (NativeHandle handle) : base (handle)
{
throw new PlatformNotSupportedException (Constants.TypeRemovedAllPlatforms);
}

public CKFetchNotificationChangesOperation ()
: base (NSObjectFlag.Empty)
{
throw new PlatformNotSupportedException (Constants.TypeRemovedAllPlatforms);
}

public CKFetchNotificationChangesOperation (CKServerChangeToken? previousServerChangeToken)
: base (NSObjectFlag.Empty)
{
throw new PlatformNotSupportedException (Constants.TypeRemovedAllPlatforms);
}

public unsafe virtual global::System.Action<CKServerChangeToken, NSError>? Completed {
get {
throw new PlatformNotSupportedException (Constants.TypeRemovedAllPlatforms);
}
set {
throw new PlatformNotSupportedException (Constants.TypeRemovedAllPlatforms);
}
}

public virtual bool MoreComing {
get {
throw new PlatformNotSupportedException (Constants.TypeRemovedAllPlatforms);
}
}

public unsafe virtual global::System.Action<CKNotification>? NotificationChanged {
get {
throw new PlatformNotSupportedException (Constants.TypeRemovedAllPlatforms);
}
set {
throw new PlatformNotSupportedException (Constants.TypeRemovedAllPlatforms);
}
}

public virtual CKServerChangeToken? PreviousServerChangeToken {
get {
throw new PlatformNotSupportedException (Constants.TypeRemovedAllPlatforms);
}
set {
throw new PlatformNotSupportedException (Constants.TypeRemovedAllPlatforms);
}
}

public virtual nuint ResultsLimit {
get {
throw new PlatformNotSupportedException (Constants.TypeRemovedAllPlatforms);
}
set {
throw new PlatformNotSupportedException (Constants.TypeRemovedAllPlatforms);
}
}
} /* class CKFetchNotificationChangesOperation */
}

#endif // !XAMCORE_5_0
67 changes: 67 additions & 0 deletions src/CloudKit/CKMarkNotificationsReadOperation.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#if !XAMCORE_5_0

using System;
using System.ComponentModel;
using System.Runtime.Versioning;
using System.Diagnostics.CodeAnalysis;

using Foundation;
using ObjCRuntime;

#nullable enable

#if !NET
using NativeHandle = System.IntPtr;
#endif

namespace CloudKit {
[Register ("CKMarkNotificationsReadOperation", SkipRegistration = true)]
#if NET
[UnsupportedOSPlatform ("ios", "Use 'CKDatabaseSubscription', 'CKFetchDatabaseChangesOperation' and 'CKFetchRecordZoneChangesOperation' instead.")]
[UnsupportedOSPlatform ("macos", "Use 'CKDatabaseSubscription', 'CKFetchDatabaseChangesOperation' and 'CKFetchRecordZoneChangesOperation' instead.")]
[UnsupportedOSPlatform ("tvos", "Use 'CKDatabaseSubscription', 'CKFetchDatabaseChangesOperation' and 'CKFetchRecordZoneChangesOperation' instead.")]
[UnsupportedOSPlatform ("maccatalyst", "Use 'CKDatabaseSubscription', 'CKFetchDatabaseChangesOperation' and 'CKFetchRecordZoneChangesOperation' instead.")]
#endif
[EditorBrowsable (EditorBrowsableState.Never)]
public unsafe partial class CKMarkNotificationsReadOperation : CKOperation {
public override NativeHandle ClassHandle { get => throw new PlatformNotSupportedException (Constants.TypeRemovedAllPlatforms); }

protected CKMarkNotificationsReadOperation (NSObjectFlag t) : base (t)
{
throw new PlatformNotSupportedException (Constants.TypeRemovedAllPlatforms);
}

protected internal CKMarkNotificationsReadOperation (NativeHandle handle) : base (handle)
{
throw new PlatformNotSupportedException (Constants.TypeRemovedAllPlatforms);
}

public CKMarkNotificationsReadOperation (CKNotificationID [] notificationIds)
: base (NSObjectFlag.Empty)
{
throw new PlatformNotSupportedException (Constants.TypeRemovedAllPlatforms);
}

public unsafe virtual CKMarkNotificationsReadHandler? Completed {
get {
throw new PlatformNotSupportedException (Constants.TypeRemovedAllPlatforms);
}
set {
throw new PlatformNotSupportedException (Constants.TypeRemovedAllPlatforms);
}
}

public virtual CKNotificationID []? NotificationIds {
get {
throw new PlatformNotSupportedException (Constants.TypeRemovedAllPlatforms);
}
set {
throw new PlatformNotSupportedException (Constants.TypeRemovedAllPlatforms);
}
}
} /* class CKMarkNotificationsReadOperation */

[EditorBrowsable (EditorBrowsableState.Never)]
public delegate void CKMarkNotificationsReadHandler (CKNotificationID [] notificationIDsMarkedRead, NSError operationError);
}
#endif // !XAMCORE_5_0
74 changes: 74 additions & 0 deletions src/CloudKit/CKModifyBadgeOperation.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#if !XAMCORE_5_0

using System;
using System.ComponentModel;
using System.Runtime.Versioning;
using System.Diagnostics.CodeAnalysis;

using Foundation;
using ObjCRuntime;

#nullable enable

#if !NET
using NativeHandle = System.IntPtr;
#endif

namespace CloudKit {
[Register ("CKModifyBadgeOperation", SkipRegistration = true)]
#if NET
[UnsupportedOSPlatform ("ios", "Modifying badge counts is no longer supported.")]
[UnsupportedOSPlatform ("macos", "Modifying badge counts is no longer supported.")]
[UnsupportedOSPlatform ("tvos", "Modifying badge counts is no longer supported.")]
[UnsupportedOSPlatform ("maccatalyst", "Modifying badge counts is no longer supported.")]
#else
[Deprecated (PlatformName.MacOSX, 15, 0, message: "Modifying badge counts is no longer supported.")]
[Deprecated (PlatformName.iOS, 18, 0, message: "Modifying badge counts is no longer supported.")]
[Deprecated (PlatformName.WatchOS, 11, 0, message: "Modifying badge counts is no longer supported.")]
[Deprecated (PlatformName.TvOS, 18, 0, message: "Modifying badge counts is no longer supported.")]
#endif
[EditorBrowsable (EditorBrowsableState.Never)]
public class CKModifyBadgeOperation : CKOperation {
public override NativeHandle ClassHandle { get => throw new PlatformNotSupportedException (Constants.TypeRemovedAllPlatforms); }

public CKModifyBadgeOperation () : base (NSObjectFlag.Empty)
{
throw new PlatformNotSupportedException (Constants.TypeRemovedAllPlatforms);
}

protected CKModifyBadgeOperation (NSObjectFlag t) : base (t)
{
throw new PlatformNotSupportedException (Constants.TypeRemovedAllPlatforms);
}

protected internal CKModifyBadgeOperation (NativeHandle handle) : base (handle)
{
throw new PlatformNotSupportedException (Constants.TypeRemovedAllPlatforms);
}

public CKModifyBadgeOperation (nuint badgeValue)
: base (NSObjectFlag.Empty)
{
throw new PlatformNotSupportedException (Constants.TypeRemovedAllPlatforms);
}

public virtual nuint BadgeValue {
get {
throw new PlatformNotSupportedException (Constants.TypeRemovedAllPlatforms);
}
set {
throw new PlatformNotSupportedException (Constants.TypeRemovedAllPlatforms);
}
}

public unsafe virtual global::System.Action<NSError>? Completed {
get {
throw new PlatformNotSupportedException (Constants.TypeRemovedAllPlatforms);
}
set {
throw new PlatformNotSupportedException (Constants.TypeRemovedAllPlatforms);
}
}
} /* class CKModifyBadgeOperation */
}
#endif // !XAMCORE_5_0
108 changes: 9 additions & 99 deletions src/cloudkit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ interface CKUserIdentity : NSSecureCoding, NSCopying {

[NoTV]
[MacCatalyst (13, 1)]
[Deprecated (PlatformName.WatchOS, 11, 0, message: "Please read Apple's document about 'Sharing CloudKit Data with Other iCloud Users'.")]
[Deprecated (PlatformName.TvOS, 18, 0, message: "Please read Apple's document about 'Sharing CloudKit Data with Other iCloud Users'.")]
[Deprecated (PlatformName.iOS, 18, 0, message: "Please read Apple's document about 'Sharing CloudKit Data with Other iCloud Users'.")]
[Deprecated (PlatformName.MacCatalyst, 18, 0, message: "Please read Apple's document about 'Sharing CloudKit Data with Other iCloud Users'.")]
[Deprecated (PlatformName.MacOSX, 15, 0, message: "Please read Apple's document about 'Sharing CloudKit Data with Other iCloud Users'.")]
[Export ("contactIdentifiers", ArgumentSemantic.Copy)]
string [] ContactIdentifiers { get; }
}
Expand Down Expand Up @@ -217,6 +222,10 @@ interface CKShareParticipant : NSSecureCoding, NSCopying {

[Export ("permission", ArgumentSemantic.Assign)]
CKShareParticipantPermission Permission { get; set; }

// This showed up in Xcode 16's b1 headers, but according to the availability attributes it's always been available.
[Export ("participantID", ArgumentSemantic.Copy)]
string ParticipantId { get; }
}

[MacCatalyst (13, 1)]
Expand Down Expand Up @@ -525,48 +534,6 @@ interface CKErrorFields {
NSString UserDidResetEncryptedDataKey { get; }
}

[BaseType (typeof (CKOperation))]
[Deprecated (PlatformName.iOS, 11, 0, message: "Use 'CKDatabaseSubscription', 'CKFetchDatabaseChangesOperation' and 'CKFetchRecordZoneChangesOperation' instead.")]
[Deprecated (PlatformName.MacOSX, 10, 13, message: "Use 'CKDatabaseSubscription', 'CKFetchDatabaseChangesOperation' and 'CKFetchRecordZoneChangesOperation' instead.")]
[Deprecated (PlatformName.WatchOS, 4, 0, message: "Use 'CKDatabaseSubscription', 'CKFetchDatabaseChangesOperation' and 'CKFetchRecordZoneChangesOperation' instead.")]
[Deprecated (PlatformName.TvOS, 11, 0, message: "Use 'CKDatabaseSubscription', 'CKFetchDatabaseChangesOperation' and 'CKFetchRecordZoneChangesOperation' instead.")]
[MacCatalyst (13, 1)]
[Deprecated (PlatformName.MacCatalyst, 13, 1, message: "Use 'CKDatabaseSubscription', 'CKFetchDatabaseChangesOperation' and 'CKFetchRecordZoneChangesOperation' instead.")]
[DisableDefaultCtor] // designated
interface CKFetchNotificationChangesOperation {

[DesignatedInitializer]
[Export ("init")]
NativeHandle Constructor ();

[Export ("initWithPreviousServerChangeToken:")]
NativeHandle Constructor ([NullAllowed] CKServerChangeToken previousServerChangeToken);

[NullAllowed] // by default this property is null
[Export ("previousServerChangeToken", ArgumentSemantic.Copy)]
CKServerChangeToken PreviousServerChangeToken { get; set; }

[Export ("resultsLimit")]
nuint ResultsLimit { get; set; }

[Export ("moreComing")]
bool MoreComing { get; }

[NullAllowed] // by default this property is null
[Export ("notificationChangedBlock", ArgumentSemantic.Copy)]
Action<CKNotification> NotificationChanged {
get;
set;
}

[NullAllowed] // by default this property is null
[Export ("fetchNotificationChangesCompletionBlock", ArgumentSemantic.Copy)]
Action<CKServerChangeToken, NSError> Completed {
get;
set;
}
}

[MacCatalyst (13, 1)]
[DisableDefaultCtor] // Objective-C exception thrown. Name: CKException Reason: You can't call init on CKServerChangeToken
[BaseType (typeof (NSObject))]
Expand Down Expand Up @@ -890,63 +857,6 @@ interface CKLocationSortDescriptor : NSSecureCoding {
CLLocation RelativeLocation { get; }
}

[MacCatalyst (13, 1)]
delegate void CKMarkNotificationsReadHandler (CKNotificationID [] notificationIDsMarkedRead, NSError operationError);

[BaseType (typeof (CKOperation))]
[DisableDefaultCtor] // NSInvalidArgumentException Reason: You must call -[CKMarkNotificationsReadOperation initWithNotificationIDsToMarkRead:]
[Deprecated (PlatformName.iOS, 11, 0, message: "Use 'CKDatabaseSubscription', 'CKFetchDatabaseChangesOperation' and 'CKFetchRecordZoneChangesOperation' instead.")]
[Deprecated (PlatformName.MacOSX, 10, 13, message: "Use 'CKDatabaseSubscription', 'CKFetchDatabaseChangesOperation' and 'CKFetchRecordZoneChangesOperation' instead.")]
[Deprecated (PlatformName.WatchOS, 4, 0, message: "Use 'CKDatabaseSubscription', 'CKFetchDatabaseChangesOperation' and 'CKFetchRecordZoneChangesOperation' instead.")]
[Deprecated (PlatformName.TvOS, 11, 0, message: "Use 'CKDatabaseSubscription', 'CKFetchDatabaseChangesOperation' and 'CKFetchRecordZoneChangesOperation' instead.")]
[MacCatalyst (13, 1)]
[Deprecated (PlatformName.MacCatalyst, 13, 1, message: "Use 'CKDatabaseSubscription', 'CKFetchDatabaseChangesOperation' and 'CKFetchRecordZoneChangesOperation' instead.")]
interface CKMarkNotificationsReadOperation {

[DesignatedInitializer]
[Export ("initWithNotificationIDsToMarkRead:")]
NativeHandle Constructor (CKNotificationID [] notificationIds);

[NullAllowed]
[Export ("notificationIDs", ArgumentSemantic.Copy)]
CKNotificationID [] NotificationIds { get; set; }

[NullAllowed]
[Export ("markNotificationsReadCompletionBlock", ArgumentSemantic.Copy)]
CKMarkNotificationsReadHandler Completed {
get;
set;
}
}

#if WATCH
[DisableDefaultCtor] // does not work on watchOS, working stub provided to ease source compatibility
#else
[DesignatedDefaultCtor]
#endif
[BaseType (typeof (CKOperation))]
[Deprecated (PlatformName.iOS, 11, 0)]
[Deprecated (PlatformName.MacOSX, 10, 13)]
[Deprecated (PlatformName.WatchOS, 4, 0)]
[Deprecated (PlatformName.TvOS, 11, 0)]
[MacCatalyst (13, 1)]
[Deprecated (PlatformName.MacCatalyst, 13, 1)]
interface CKModifyBadgeOperation {

[Export ("initWithBadgeValue:")]
NativeHandle Constructor (nuint badgeValue);

[Export ("badgeValue", ArgumentSemantic.UnsafeUnretained)]
nuint BadgeValue { get; set; }

[NullAllowed] // by default this property is null
[Export ("modifyBadgeCompletionBlock", ArgumentSemantic.Copy)]
Action<NSError> Completed {
get;
set;
}
}

[MacCatalyst (13, 1)]
delegate void CKModifyRecordsOperationHandler (CKRecord [] savedRecords, CKRecordID [] deletedRecordIds, NSError operationError);

Expand Down
Loading

10 comments on commit f3a7879

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

Please sign in to comment.