Skip to content

Commit ee2005b

Browse files
author
victor kachalov
committed
introduce WorkoutRoute
1 parent be49c11 commit ee2005b

File tree

107 files changed

+1912
-1086
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+1912
-1086
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## [1.6.3] - 16.04.2022.
2+
3+
* add from dictionary static factory for WorkoutRoute
4+
* minor fixes in the code
5+
16
## [1.6.2] - 23.10.2021.
27

38
* Fix timestamps bug

Example/HealthKitReporter.xcodeproj/project.pbxproj

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@
243243
CreatedOnToolsVersion = 6.3.1;
244244
DevelopmentTeam = MAVP5V2N7V;
245245
LastSwiftMigration = 1200;
246-
ProvisioningStyle = Manual;
246+
ProvisioningStyle = Automatic;
247247
};
248248
607FACE41AFB9204008FA782 = {
249249
CreatedOnToolsVersion = 6.3.1;
@@ -474,7 +474,7 @@
474474
GCC_WARN_UNUSED_FUNCTION = YES;
475475
GCC_WARN_UNUSED_VARIABLE = YES;
476476
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
477-
MARKETING_VERSION = 1.6.2;
477+
MARKETING_VERSION = 1.6.3;
478478
MTL_ENABLE_DEBUG_INFO = YES;
479479
ONLY_ACTIVE_ARCH = YES;
480480
SDKROOT = iphoneos;
@@ -525,7 +525,7 @@
525525
GCC_WARN_UNUSED_FUNCTION = YES;
526526
GCC_WARN_UNUSED_VARIABLE = YES;
527527
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
528-
MARKETING_VERSION = 1.6.2;
528+
MARKETING_VERSION = 1.6.3;
529529
MTL_ENABLE_DEBUG_INFO = NO;
530530
SDKROOT = iphoneos;
531531
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
@@ -539,15 +539,15 @@
539539
buildSettings = {
540540
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
541541
CODE_SIGN_ENTITLEMENTS = HealthKitReporter_Example.entitlements;
542-
CODE_SIGN_IDENTITY = "iPhone Developer";
543-
CODE_SIGN_STYLE = Manual;
544-
DEVELOPMENT_TEAM = MAVP5V2N7V;
542+
CODE_SIGN_IDENTITY = "Apple Development";
543+
CODE_SIGN_STYLE = Automatic;
544+
DEVELOPMENT_TEAM = "";
545545
INFOPLIST_FILE = HealthKitReporter/Info.plist;
546546
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
547547
MODULE_NAME = ExampleApp;
548548
PRODUCT_BUNDLE_IDENTIFIER = "com.kvs.demo.$(PRODUCT_NAME:rfc1034identifier)";
549549
PRODUCT_NAME = "$(TARGET_NAME)";
550-
PROVISIONING_PROFILE_SPECIFIER = HealthKitReporter;
550+
PROVISIONING_PROFILE_SPECIFIER = "";
551551
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
552552
SWIFT_VERSION = 5.0;
553553
};
@@ -559,15 +559,15 @@
559559
buildSettings = {
560560
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
561561
CODE_SIGN_ENTITLEMENTS = HealthKitReporter_Example.entitlements;
562-
CODE_SIGN_IDENTITY = "iPhone Developer";
563-
CODE_SIGN_STYLE = Manual;
564-
DEVELOPMENT_TEAM = MAVP5V2N7V;
562+
CODE_SIGN_IDENTITY = "Apple Development";
563+
CODE_SIGN_STYLE = Automatic;
564+
DEVELOPMENT_TEAM = "";
565565
INFOPLIST_FILE = HealthKitReporter/Info.plist;
566566
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
567567
MODULE_NAME = ExampleApp;
568568
PRODUCT_BUNDLE_IDENTIFIER = "com.kvs.demo.$(PRODUCT_NAME:rfc1034identifier)";
569569
PRODUCT_NAME = "$(TARGET_NAME)";
570-
PROVISIONING_PROFILE_SPECIFIER = HealthKitReporter;
570+
PROVISIONING_PROFILE_SPECIFIER = "";
571571
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
572572
SWIFT_VERSION = 5.0;
573573
};

Example/HealthKitReporter/Base.lproj/Main.storyboard

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="19162" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="vXZ-lx-hvc">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="20037" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="vXZ-lx-hvc">
33
<device id="retina4_7" orientation="portrait" appearance="light"/>
44
<dependencies>
55
<deployment identifier="iOS"/>
6-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19144"/>
6+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="20020"/>
77
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
88
</dependencies>
99
<scenes>
@@ -46,9 +46,9 @@
4646
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="HXp-HY-J8w">
4747
<rect key="frame" x="0.0" y="150" width="115" height="31"/>
4848
<state key="normal" title="Button"/>
49-
<buttonConfiguration key="configuration" style="plain" title="HR Series"/>
49+
<buttonConfiguration key="configuration" style="plain" title="Read Series"/>
5050
<connections>
51-
<action selector="hrSeriesButtonTapped:" destination="vXZ-lx-hvc" eventType="touchUpInside" id="uct-CN-Mj7"/>
51+
<action selector="seriesButtonTapped:" destination="vXZ-lx-hvc" eventType="touchUpInside" id="80C-FW-PgF"/>
5252
</connections>
5353
</button>
5454
</subviews>

Example/HealthKitReporter/LocalNotificationManager.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
// Copyright © 2020 Victor Kachalov. All rights reserved.
77
//
88

9-
import Foundation
109
import UserNotifications
1110

1211
class LocalNotificationManager {

Example/HealthKitReporter/ViewController.swift

Lines changed: 46 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,23 @@ class ViewController: UIViewController {
1919
QuantityType.heartRate,
2020
CategoryType.sleepAnalysis,
2121
QuantityType.heartRateVariabilitySDNN,
22-
SeriesType.heartbeatSeries
22+
SeriesType.heartbeatSeries,
23+
WorkoutType.workoutType,
24+
SeriesType.workoutRoute
2325
]
2426
private let typesToWrite: [QuantityType] = [
2527
.stepCount
2628
]
2729

30+
var predicate: NSPredicate {
31+
let now = Date()
32+
return Query.predicateForSamples(
33+
withStart: now.addingTimeInterval(-1 * 3600 * 3600 * 24),
34+
end: now,
35+
options: .strictEndDate
36+
)
37+
}
38+
2839
override func viewDidLoad() {
2940
super.viewDidLoad()
3041
do {
@@ -85,15 +96,41 @@ class ViewController: UIViewController {
8596
}
8697
}
8798
}
88-
@IBAction func hrSeriesButtonTapped(_ sender: UIButton) {
89-
readSeries()
99+
@IBAction func seriesButtonTapped(_ sender: UIButton) {
100+
readRoutes()
101+
}
102+
103+
private func readHrSeries() {
104+
let manager = reporter?.manager
105+
let reader = reporter?.reader
106+
do {
107+
if let seriesQuery = try reader?.heartbeatSeriesQuery(
108+
predicate: predicate,
109+
resultsHandler: { samples, error in
110+
if error == nil {
111+
do {
112+
print(try samples.encoded())
113+
} catch {
114+
print(error)
115+
}
116+
} else {
117+
print(error ?? "error")
118+
}
119+
}) {
120+
manager?.executeQuery(seriesQuery)
121+
}
122+
} catch {
123+
print(error)
124+
}
90125
}
91126

92-
private func readSeries() {
127+
private func readRoutes() {
93128
let manager = reporter?.manager
94129
let reader = reporter?.reader
95130
do {
96-
if let seriesQuery = try reader?.heartbeatSeriesQuery(resultsHandler: { samples, error in
131+
if let seriesQuery = try reader?.workoutRouteQuery(
132+
predicate: predicate,
133+
resultsHandler: { samples, error in
97134
if error == nil {
98135
do {
99136
print(try samples.encoded())
@@ -166,7 +203,10 @@ class ViewController: UIViewController {
166203
let manager = reporter?.manager
167204
let reader = reporter?.reader
168205
do {
169-
if let query = try reader?.categoryQuery(type: .sleepAnalysis, resultsHandler: { results, error in
206+
if let query = try reader?.categoryQuery(
207+
type: .sleepAnalysis,
208+
predicate: predicate,
209+
resultsHandler: { results, error in
170210
if error == nil {
171211
for element in results {
172212
do {

Example/Podfile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
platform :ios, '9.0'
12
use_frameworks!
23

34
target 'HealthKitReporter_Example' do
4-
pod 'HealthKitReporter', :path => '../'
5-
6-
target 'HealthKitReporter_Tests' do
7-
inherit! :search_paths
5+
pod 'HealthKitReporter', :path => '../', :testspecs => ['Tests']
6+
end
87

9-
10-
end
8+
target 'HealthKitReporter_Tests' do
9+
inherit! :search_paths
1110
end
11+

Example/Podfile.lock

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
PODS:
2-
- HealthKitReporter (0.1.0)
2+
- HealthKitReporter (1.6.3)
3+
- HealthKitReporter/Tests (1.6.3)
34

45
DEPENDENCIES:
56
- HealthKitReporter (from `../`)
7+
- HealthKitReporter/Tests (from `../`)
68

79
EXTERNAL SOURCES:
810
HealthKitReporter:
911
:path: "../"
1012

1113
SPEC CHECKSUMS:
12-
HealthKitReporter: 101f590db77a0c3153df14478144b85879d6fba8
14+
HealthKitReporter: 42ebaa50989c4e4f6171b2caa3388c53519bea33
1315

14-
PODFILE CHECKSUM: 23abae3089785275304b0626e117fcbe304f3915
16+
PODFILE CHECKSUM: 42dc208a4788fd9b7d8eebf0c62dd84606fddf4d
1517

16-
COCOAPODS: 1.9.3
18+
COCOAPODS: 1.11.2

Example/Pods/Local Podspecs/HealthKitReporter.podspec.json

Lines changed: 19 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Example/Pods/Manifest.lock

Lines changed: 6 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)