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

[HealthKit] Add support for Xcode 15 beta 7 #18927

Merged
32 changes: 32 additions & 0 deletions src/HealthKit/Enums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,8 @@ public enum HKWorkoutActivityType : ulong {
SwimBikeRun = 82,
[Watch (9, 0), MacCatalyst (16, 0), Mac (13, 0), iOS (16, 0), NoTV]
Transition = 83,
[Watch (10, 0), MacCatalyst (17, 0), Mac (14, 0), iOS (17, 0), NoTV]
UnderwaterDiving,
[MacCatalyst (13, 1)]
Other = 3000
}
Expand Down Expand Up @@ -721,4 +723,34 @@ public enum HKVisionPrescriptionType : ulong {
Glasses = 1,
Contacts,
}

[Watch (10, 0), MacCatalyst (17, 0), Mac (14, 0), iOS (17, 0)]
[Native]
public enum HKCyclingFunctionalThresholdPowerTestType : long {
MaxExercise60Minute = 1,
MaxExercise20Minute,
RampTest,
PredictionExercise,
}

[Watch (10, 0), MacCatalyst (17, 0), Mac (14, 0), iOS (17, 0)]
[Native]
public enum HKPhysicalEffortEstimationType : long {
ActivityLookup = 1,
DeviceSensed,
}

[Watch (10, 0), MacCatalyst (17, 0), Mac (14, 0), iOS (17, 0)]
[Native]
public enum HKWaterSalinity : long {
FreshWater = 1,
SaltWater,
}

[Watch (10, 0), iOS (17, 0)]
[Native]
public enum HKWorkoutSessionType : long {
Primary = 0,
Mirrored,
}
}
137 changes: 116 additions & 21 deletions src/healthkit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ public enum HKErrorCode : long {
UserExitedWorkoutSession,
RequiredAuthorizationDenied,
NoData,
WorkoutActivityNotAllowed,
DataSizeExceeded,
BackgroundWorkoutSessionNotAllowed,
}

[Mac (13, 0)]
Expand All @@ -60,9 +63,9 @@ public enum HKWorkoutSessionLocationType : long {
Outdoor
}

[NoiOS]
[iOS (17, 0)]
[Mac (13, 0)]
[NoMacCatalyst]
[MacCatalyst (17, 0)]
[Native]
public enum HKWorkoutSessionState : long {
NotStarted = 1,
Expand Down Expand Up @@ -717,6 +720,10 @@ interface HKHealthStore {

// HKWorkout category

[Deprecated (PlatformName.iOS, 17, 0, message: "Use 'HKWorkoutBuilder.Add (HKSample [] samples, HKWorkoutBuilderCompletionHandler completionHandler)' instead.")]
[Deprecated (PlatformName.WatchOS, 10, 0, message: "Use 'HKWorkoutBuilder.Add (HKSample [] samples, HKWorkoutBuilderCompletionHandler completionHandler)' instead.")]
[Deprecated (PlatformName.MacCatalyst, 16, 0, message: "Use 'HKWorkoutBuilder.Add (HKSample [] samples, HKWorkoutBuilderCompletionHandler completionHandler)' instead.")]
[Deprecated (PlatformName.MacOSX, 14, 0, message: "Use 'HKWorkoutBuilder.Add (HKSample [] samples, HKWorkoutBuilderCompletionHandler completionHandler)' instead.")]
[Export ("addSamples:toWorkout:completion:")]
void AddSamples (HKSample [] samples, HKWorkout workout, HKStoreSampleAddedCallback callback);

Expand Down Expand Up @@ -784,6 +791,11 @@ interface HKHealthStore {
[Async]
[Export ("requestPerObjectReadAuthorizationForType:predicate:completion:")]
void RequestPerObjectReadAuthorization (HKObjectType objectType, [NullAllowed] NSPredicate predicate, HKHealthStoreCompletionHandler completion);

[NullAllowed]
[iOS (17, 0), Mac (14, 0), Watch (10, 0), NoTV, MacCatalyst (17, 0)]
[Export ("workoutSessionMirroringStartHandler", ArgumentSemantic.Copy)]
Action<HKWorkoutSession> WorkoutSessionMirroringStartHandler { get; set; }
}

delegate void HKStoreSampleAddedCallback (bool success, NSError error);
Expand Down Expand Up @@ -1233,6 +1245,30 @@ interface HKMetadataKey {
[Watch (9, 0), MacCatalyst (16, 0), Mac (13, 0), iOS (16, 0)]
[Field ("HKMetadataKeyUserMotionContext")]
NSString UserMotionContext { get; }

[Watch (10, 0), MacCatalyst (17, 0), Mac (14, 0), iOS (17, 0)]
[Field ("HKMetadataKeyActivityType")]
NSString KeyActivityType { get; }

[Watch (10, 0), MacCatalyst (17, 0), Mac (14, 0), iOS (17, 0)]
[Field ("HKMetadataKeyPhysicalEffortEstimationType")]
NSString PhysicalEffortEstimationType { get; }

[Watch (10, 0), MacCatalyst (17, 0), Mac (14, 0), iOS (17, 0)]
[Field ("HKMetadataKeyAppleFitnessPlusSession")]
NSString AppleFitnessPlusSession { get; }

[Watch (10, 0), MacCatalyst (17, 0), Mac (14, 0), iOS (17, 0)]
[Field ("HKMetadataKeyCyclingFunctionalThresholdPowerTestType")]
NSString CyclingFunctionalThresholdPowerTestType { get; }

[Watch (10, 0), MacCatalyst (17, 0), Mac (14, 0), iOS (17, 0)]
[Field ("HKMetadataKeyMaximumLightIntensity")]
NSString MaximumLightIntensity { get; }

[Watch (10, 0), MacCatalyst (17, 0), Mac (14, 0), iOS (17, 0)]
[Field ("HKMetadataKeyWaterSalinity")]
NSString WaterSalinity { get; }
}

[Mac (13, 0)]
Expand Down Expand Up @@ -2390,6 +2426,34 @@ enum HKQuantityTypeIdentifier {
[Watch (9, 0), MacCatalyst (16, 0), Mac (13, 0), iOS (16, 0)]
[Field ("HKQuantityTypeIdentifierWaterTemperature")]
WaterTemperature,

[Watch (10, 0), MacCatalyst (17, 0), Mac (14, 0), iOS (17, 0)]
[Field ("HKQuantityTypeIdentifierCyclingCadence")]
CyclingCadence,

[Watch (10, 0), MacCatalyst (17, 0), Mac (14, 0), iOS (17, 0)]
[Field ("HKQuantityTypeIdentifierCyclingFunctionalThresholdPower")]
CyclingFunctionalThresholdPower,

[Watch (10, 0), MacCatalyst (17, 0), Mac (14, 0), iOS (17, 0)]
[Field ("HKQuantityTypeIdentifierCyclingPower")]
CyclingPower,

[Watch (10, 0), MacCatalyst (17, 0), Mac (14, 0), iOS (17, 0)]
[Field ("HKQuantityTypeIdentifierCyclingSpeed")]
CyclingSpeed,

[Watch (9, 0), MacCatalyst (16, 0), Mac (13, 0), iOS (16, 0)]
[Field ("HKQuantityTypeIdentifierEnvironmentalSoundReduction")]
EnvironmentalSoundReduction,

[Watch (10, 0), MacCatalyst (17, 0), Mac (14, 0), iOS (17, 0)]
[Field ("HKQuantityTypeIdentifierPhysicalEffort")]
PhysicalEffort,

[Watch (10, 0), MacCatalyst (17, 0), Mac (14, 0), iOS (17, 0)]
[Field ("HKQuantityTypeIdentifierTimeInDaylight")]
TimeInDaylight,
}

[Mac (13, 0)]
Expand Down Expand Up @@ -3099,6 +3163,16 @@ interface HKUnit : NSCopying, NSSecureCoding {
[Static]
[Export ("degreeAngleUnit")]
HKUnit DegreeAngle { get; }

[Watch (10, 0), MacCatalyst (17, 0), Mac (14, 0), iOS (17, 0), NoTV]
[Static]
[Export ("luxUnitWithMetricPrefix:")]
HKUnit LuxUnitWithMetricPrefix (HKMetricPrefix prefix);
haritha-mohan marked this conversation as resolved.
Show resolved Hide resolved

[Watch (10, 0), MacCatalyst (17, 0), Mac (14, 0), iOS (17, 0), NoTV]
[Static]
[Export ("luxUnit")]
HKUnit LuxUnit ();
haritha-mohan marked this conversation as resolved.
Show resolved Hide resolved
}

[Mac (13, 0)]
Expand Down Expand Up @@ -3477,10 +3551,9 @@ interface HKQueryAnchor : NSSecureCoding, NSCopying {
HKQueryAnchor Create (nuint value);
}


[NoiOS]
[Mac (13, 0)]
[NoMacCatalyst]
[iOS (17, 0)]
[MacCatalyst (17, 0)]
[BaseType (typeof (NSObject))]
[DisableDefaultCtor]
interface HKWorkoutSession : NSSecureCoding {
Expand All @@ -3492,7 +3565,6 @@ interface HKWorkoutSession : NSSecureCoding {
[Export ("locationType")]
HKWorkoutSessionLocationType LocationType { get; }

[NoMacCatalyst]
[Export ("workoutConfiguration", ArgumentSemantic.Copy)]
HKWorkoutConfiguration WorkoutConfiguration { get; }

Expand All @@ -3513,71 +3585,87 @@ interface HKWorkoutSession : NSSecureCoding {
[NullAllowed, Export ("endDate")]
NSDate EndDate { get; }

[NoiOS]
[NoMacCatalyst]
[Deprecated (PlatformName.WatchOS, 3, 0, message: "Use HKWorkoutSession (HKHealthStore, HKWorkoutConfiguration, out NSError) instead.")]
[Export ("initWithActivityType:locationType:")]
NativeHandle Constructor (HKWorkoutActivityType activityType, HKWorkoutSessionLocationType locationType);

[Deprecated (PlatformName.WatchOS, 5, 0, message: "Use HKWorkoutSession (HKHealthStore, HKWorkoutConfiguration, out NSError) instead.")]
[NoiOS]
[NoMacCatalyst]
[Deprecated (PlatformName.WatchOS, 5, 0, message: "Use HKWorkoutSession (HKHealthStore, HKWorkoutConfiguration, out NSError) instead.")]
[Export ("initWithConfiguration:error:")]
NativeHandle Constructor (HKWorkoutConfiguration workoutConfiguration, out NSError error);

[NoiOS]
[Watch (5, 0)]
[NoMacCatalyst]
[Export ("initWithHealthStore:configuration:error:")]
NativeHandle Constructor (HKHealthStore healthStore, HKWorkoutConfiguration workoutConfiguration, [NullAllowed] out NSError error);

[Watch (5, 0)]
[NoMacCatalyst]
[Export ("prepare")]
void Prepare ();

[Watch (5, 0)]
[NoMacCatalyst]
[Export ("startActivityWithDate:")]
void StartActivity ([NullAllowed] NSDate date);

[Watch (5, 0)]
[NoMacCatalyst]
[Export ("stopActivityWithDate:")]
void StopActivity ([NullAllowed] NSDate date);

[Watch (5, 0)]
[NoMacCatalyst]
[Export ("end")]
void End ();

[Watch (5, 0)]
[NoMacCatalyst]
[Export ("pause")]
void Pause ();

[Watch (5, 0)]
[NoMacCatalyst]
[Export ("resume")]
void Resume ();

[NoiOS]
[Watch (5, 0)]
[NoMacCatalyst]
[Export ("associatedWorkoutBuilder")]
HKLiveWorkoutBuilder AssociatedWorkoutBuilder { get; }

[Watch (9, 0), NoTV, NoiOS, NoMacCatalyst]
[Watch (9, 0), NoTV]
[Export ("beginNewActivityWithConfiguration:date:metadata:")]
void BeginNewActivity (HKWorkoutConfiguration workoutConfiguration, NSDate date, [NullAllowed] NSDictionary<NSString, NSObject> metadata);

[Watch (9, 0), NoTV, NoiOS, NoMacCatalyst]
[Watch (9, 0), NoTV]
[Export ("endCurrentActivityOnDate:")]
void EndCurrentActivity (NSDate date);

[Watch (9, 0), NoTV, NoiOS, NoMacCatalyst]
[Watch (9, 0), NoTV]
[Export ("currentActivity", ArgumentSemantic.Copy)]
HKWorkoutActivity CurrentActivity { get; }

[Watch (10, 0), NoTV, Mac (14, 0)]
[Export ("type")]
HKWorkoutSessionType Type { get; }

[Watch (10, 0), NoTV, NoMacCatalyst, NoMac, iOS (17, 0)]
[Export ("sendDataToRemoteWorkoutSession:completion:")]
[Async]
void SendDataToRemoteWorkoutSession (NSData data, Action<bool, NSError> completion);

[Watch (10, 0), NoTV, NoMacCatalyst, NoMac, NoiOS]
[Export ("startMirroringToCompanionDeviceWithCompletion:")]
void StartMirroringToCompanionDeviceWithCompletion (Action<bool, NSError> completion);
haritha-mohan marked this conversation as resolved.
Show resolved Hide resolved

[Watch (10, 0), NoTV, NoMacCatalyst, NoMac, NoiOS]
[Export ("stopMirroringToCompanionDeviceWithCompletion:")]
void StopMirroringToCompanionDeviceWithCompletion (Action<bool, NSError> completion);
haritha-mohan marked this conversation as resolved.
Show resolved Hide resolved
}

[NoiOS]
[Mac (13, 0)]
[NoMacCatalyst]
[iOS (17, 0)]
[MacCatalyst (17, 0)]
[Protocol, Model]
[BaseType (typeof (NSObject))]
interface HKWorkoutSessionDelegate {
Expand All @@ -3589,18 +3677,25 @@ interface HKWorkoutSessionDelegate {
[Export ("workoutSession:didFailWithError:")]
void DidFail (HKWorkoutSession workoutSession, NSError error);

[NoMacCatalyst]
// // Issue filed at: https://github.com/xamarin/maccore/issues/2609
[Export ("workoutSession:didGenerateEvent:")]
void DidGenerateEvent (HKWorkoutSession workoutSession, HKWorkoutEvent @event);

[Watch (9, 0), NoiOS, NoTV, Mac (13, 0), NoMacCatalyst]
[Watch (9, 0), NoTV, Mac (13, 0)]
[Export ("workoutSession:didBeginActivityWithConfiguration:date:")]
void DidBeginActivity (HKWorkoutSession workoutSession, HKWorkoutConfiguration workoutConfiguration, NSDate date);

[Watch (9, 0), NoiOS, NoTV, Mac (13, 0), NoMacCatalyst]
[Watch (9, 0), NoTV, Mac (13, 0)]
[Export ("workoutSession:didEndActivityWithConfiguration:date:")]
void DidEndActivity (HKWorkoutSession workoutSession, HKWorkoutConfiguration workoutConfiguration, NSDate date);

[Watch (10, 0), iOS (17, 0), MacCatalyst (17, 0), NoTV, Mac (14, 0)]
[Export ("workoutSession:didReceiveDataFromRemoteWorkoutSession:")]
void DidReceiveData (HKWorkoutSession workoutSession, NSData [] data);

[Watch (10, 0), iOS (17, 0), MacCatalyst (17, 0), NoTV, Mac (14, 0)]
[Export ("workoutSession:didDisconnectFromRemoteDeviceWithError:")]
void DidDisconnect (HKWorkoutSession workoutSession, [NullAllowed] NSError error);
}

[Mac (13, 0)]
Expand Down
8 changes: 8 additions & 0 deletions tests/introspection/iOS/iOSApiSelectorTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,14 @@ protected override bool CheckResponse (bool value, Type actualType, MethodBase m
break;
}
break;
case "HKHealthStore":
switch (name) {
case "workoutSessionMirroringStartHandler":
if (TestRuntime.IsSimulatorOrDesktop)
return true;
break;
}
break;
#endif
#if __WATCHOS__
case "INUserContext":
Expand Down
48 changes: 0 additions & 48 deletions tests/xtro-sharpie/api-annotations-dotnet/iOS-HealthKit.todo

This file was deleted.

Loading
Loading