Skip to content

Commit 9c23c37

Browse files
committed
SpeedySloth: Using HealthKit to build a workout app for Apple Watch: Version 1.0, 2016-10-04
First release This sample demonstrates how to use HealthKit to build a workout app that runs in the background, collects data from the Apple Watch sensors, and contributes to Activity rings. Signed-off-by: Liu Lantao <[email protected]>
1 parent f00f92f commit 9c23c37

30 files changed

+2260
-0
lines changed

SpeedySloth/LICENSE.txt

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
Sample code project: SpeedySloth: Using HealthKit to build a workout app for Apple Watch
2+
Version: 1.0
3+
4+
IMPORTANT: This Apple software is supplied to you by Apple
5+
Inc. ("Apple") in consideration of your agreement to the following
6+
terms, and your use, installation, modification or redistribution of
7+
this Apple software constitutes acceptance of these terms. If you do
8+
not agree with these terms, please do not use, install, modify or
9+
redistribute this Apple software.
10+
11+
In consideration of your agreement to abide by the following terms, and
12+
subject to these terms, Apple grants you a personal, non-exclusive
13+
license, under Apple's copyrights in this original Apple software (the
14+
"Apple Software"), to use, reproduce, modify and redistribute the Apple
15+
Software, with or without modifications, in source and/or binary forms;
16+
provided that if you redistribute the Apple Software in its entirety and
17+
without modifications, you must retain this notice and the following
18+
text and disclaimers in all such redistributions of the Apple Software.
19+
Neither the name, trademarks, service marks or logos of Apple Inc. may
20+
be used to endorse or promote products derived from the Apple Software
21+
without specific prior written permission from Apple. Except as
22+
expressly stated in this notice, no other rights or licenses, express or
23+
implied, are granted by Apple herein, including but not limited to any
24+
patent rights that may be infringed by your derivative works or by other
25+
works in which the Apple Software may be incorporated.
26+
27+
The Apple Software is provided by Apple on an "AS IS" basis. APPLE
28+
MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
29+
THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
30+
FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
31+
OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
32+
33+
IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
34+
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
35+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
36+
INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
37+
MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
38+
AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
39+
STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
40+
POSSIBILITY OF SUCH DAMAGE.
41+
42+
Copyright (C) 2016 Apple Inc. All Rights Reserved.

SpeedySloth/README.md

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# SpeedySloth: Using HealthKit to build a workout app for Apple Watch
2+
3+
This sample demonstrates how to use HealthKit to build a workout app that runs in the background, collects data from the Apple Watch sensors, and contributes to Activity rings.
4+
5+
## Requirements
6+
7+
### Build
8+
9+
Xcode 8.0 or later; iOS 10.0 SDK, watchOS 3.0 SDK or later
10+
11+
### Runtime
12+
13+
iOS 10.0 or later, watchOS 3.0 or later
14+
15+
Copyright (C) 2016 Apple Inc. All rights reserved.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{
2+
"images" : [
3+
{
4+
"size" : "24x24",
5+
"idiom" : "watch",
6+
"scale" : "2x",
7+
"role" : "notificationCenter",
8+
"subtype" : "38mm"
9+
},
10+
{
11+
"size" : "27.5x27.5",
12+
"idiom" : "watch",
13+
"scale" : "2x",
14+
"role" : "notificationCenter",
15+
"subtype" : "42mm"
16+
},
17+
{
18+
"size" : "29x29",
19+
"idiom" : "watch",
20+
"role" : "companionSettings",
21+
"scale" : "2x"
22+
},
23+
{
24+
"size" : "29x29",
25+
"idiom" : "watch",
26+
"role" : "companionSettings",
27+
"scale" : "3x"
28+
},
29+
{
30+
"size" : "40x40",
31+
"idiom" : "watch",
32+
"scale" : "2x",
33+
"role" : "appLauncher",
34+
"subtype" : "38mm"
35+
},
36+
{
37+
"size" : "86x86",
38+
"idiom" : "watch",
39+
"scale" : "2x",
40+
"role" : "quickLook",
41+
"subtype" : "38mm"
42+
},
43+
{
44+
"size" : "98x98",
45+
"idiom" : "watch",
46+
"scale" : "2x",
47+
"role" : "quickLook",
48+
"subtype" : "42mm"
49+
}
50+
],
51+
"info" : {
52+
"version" : 1,
53+
"author" : "xcode"
54+
}
55+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<document type="com.apple.InterfaceBuilder.WatchKit.Storyboard" version="3.0" toolsVersion="11129.6" systemVersion="15E65" targetRuntime="watchKit" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="AgC-eL-Hgc">
3+
<dependencies>
4+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11103.5"/>
5+
<plugIn identifier="com.apple.InterfaceBuilder.IBWatchKitPlugin" version="11055.3"/>
6+
</dependencies>
7+
<scenes>
8+
<!--ConfigurationInterfaceController-->
9+
<scene sceneID="aou-V4-d1y">
10+
<objects>
11+
<controller identifier="ConfigurationInterfaceController" id="AgC-eL-Hgc" customClass="ConfigurationInterfaceController" customModule="SpeedySloth_WatchKit_Extension">
12+
<items>
13+
<label alignment="left" text="Activity Type" id="JbE-ls-T0G">
14+
<fontDescription key="font" style="UICTFontTextStyleCaption2"/>
15+
</label>
16+
<picker height="38" alignment="left" focusStyle="stack" indicatorMode="shownWhileFocused" id="Cvl-Np-0ix">
17+
<connections>
18+
<action selector="activityTypePickerSelectedItemChangedWithValue:" destination="AgC-eL-Hgc" id="7sX-Cj-WaB"/>
19+
</connections>
20+
</picker>
21+
<label alignment="left" text="Location Type" id="w0Y-gV-pKv">
22+
<fontDescription key="font" style="UICTFontTextStyleCaption2"/>
23+
</label>
24+
<picker height="38" alignment="left" focusStyle="stack" indicatorMode="shownWhileFocused" id="yQ9-Eh-8Xr"/>
25+
<button width="1" alignment="left" verticalAlignment="bottom" title="Start" id="wLU-pX-ZjH">
26+
<connections>
27+
<action selector="didTapStartButton" destination="AgC-eL-Hgc" id="4LV-Ng-rNA"/>
28+
</connections>
29+
</button>
30+
</items>
31+
<connections>
32+
<outlet property="activityTypePicker" destination="Cvl-Np-0ix" id="vlU-Fd-CBb"/>
33+
<outlet property="locationTypePicker" destination="yQ9-Eh-8Xr" id="lei-VH-pKM"/>
34+
</connections>
35+
</controller>
36+
</objects>
37+
<point key="canvasLocation" x="171" y="141"/>
38+
</scene>
39+
<!--WorkoutInterfaceController-->
40+
<scene sceneID="n0q-AO-fFK">
41+
<objects>
42+
<controller identifier="WorkoutInterfaceController" id="3AD-3g-W6O" customClass="WorkoutInterfaceController" customModule="SpeedySloth_WatchKit_Extension">
43+
<items>
44+
<label alignment="left" text="Label" id="ADM-9Z-RsX">
45+
<color key="textColor" red="1" green="0.97880674710000004" blue="0.13324607359999999" alpha="1" colorSpace="calibratedRGB"/>
46+
</label>
47+
<label alignment="left" text="Label" id="OIZ-b9-Zi2">
48+
<color key="textColor" red="1" green="0.041046944600000003" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
49+
</label>
50+
<label alignment="left" text="Label" id="Eao-ZG-tZX">
51+
<color key="textColor" red="0.0" green="0.56638695100000003" blue="1" alpha="1" colorSpace="calibratedRGB"/>
52+
</label>
53+
<label width="136" alignment="left" alpha="0.0" text="Marker Saved!" textAlignment="right" id="oVG-L9-p0W">
54+
<color key="textColor" red="1" green="1" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
55+
</label>
56+
<group width="1" alignment="left" id="7cE-B0-MCY">
57+
<items>
58+
<button width="0.5" alignment="left" title="Pause" id="0xt-7N-diW">
59+
<connections>
60+
<action selector="didTapPauseResumeButton" destination="3AD-3g-W6O" id="4MJ-Sw-PnG"/>
61+
</connections>
62+
</button>
63+
<button width="0.5" alignment="left" title="Marker" id="Pnp-Yb-J7c">
64+
<connections>
65+
<action selector="didTapMarkerButton" destination="3AD-3g-W6O" id="vcd-Gk-GC5"/>
66+
</connections>
67+
</button>
68+
</items>
69+
</group>
70+
<button width="1" alignment="right" verticalAlignment="bottom" title="Stop" id="bgZ-vR-fSL">
71+
<connections>
72+
<action selector="didTapStopButton" destination="3AD-3g-W6O" id="eGL-Yc-XKR"/>
73+
</connections>
74+
</button>
75+
</items>
76+
<connections>
77+
<outlet property="caloriesLabel" destination="OIZ-b9-Zi2" id="RPQ-VI-hyp"/>
78+
<outlet property="distanceLabel" destination="Eao-ZG-tZX" id="Jhc-Sb-uhp"/>
79+
<outlet property="durationLabel" destination="ADM-9Z-RsX" id="eke-aD-t4Y"/>
80+
<outlet property="markerLabel" destination="oVG-L9-p0W" id="4O7-ts-UvL"/>
81+
<outlet property="pauseResumeButton" destination="0xt-7N-diW" id="C9y-rl-7ER"/>
82+
</connections>
83+
</controller>
84+
</objects>
85+
<point key="canvasLocation" x="375" y="152"/>
86+
</scene>
87+
<!--SummaryInterfaceController-->
88+
<scene sceneID="tRq-Ml-cM9">
89+
<objects>
90+
<controller identifier="SummaryInterfaceController" id="JTE-42-caD" customClass="SummaryInterfaceController" customModule="SpeedySloth_WatchKit_Extension">
91+
<items>
92+
<label alignment="left" text="Label" id="cl2-ui-nNn"/>
93+
<label alignment="left" text="Label" id="Kt7-je-LHa">
94+
<color key="textColor" red="1" green="0.97880674707302084" blue="0.13324607364832664" alpha="1" colorSpace="calibratedRGB"/>
95+
</label>
96+
<label alignment="left" text="Label" id="d7l-ho-0Yo">
97+
<color key="textColor" red="1" green="0.041046944598614132" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
98+
</label>
99+
<label alignment="left" text="Label" id="Wng-ib-fyp">
100+
<color key="textColor" red="0.0" green="0.56638695098710379" blue="1" alpha="1" colorSpace="calibratedRGB"/>
101+
</label>
102+
<button width="1" alignment="left" verticalAlignment="bottom" title="Done" id="s3l-fi-rwP">
103+
<connections>
104+
<action selector="didTapDoneButton" destination="JTE-42-caD" id="Yea-GW-2eW"/>
105+
</connections>
106+
</button>
107+
</items>
108+
<connections>
109+
<outlet property="caloriesLabel" destination="d7l-ho-0Yo" id="xaX-zb-yfm"/>
110+
<outlet property="distanceLabel" destination="Wng-ib-fyp" id="u0g-FN-J8a"/>
111+
<outlet property="durationLabel" destination="Kt7-je-LHa" id="2RK-GS-5yy"/>
112+
<outlet property="workoutLabel" destination="cl2-ui-nNn" id="C4V-Te-6qe"/>
113+
</connections>
114+
</controller>
115+
</objects>
116+
<point key="canvasLocation" x="580" y="152"/>
117+
</scene>
118+
</scenes>
119+
</document>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleDevelopmentRegion</key>
6+
<string>en</string>
7+
<key>CFBundleDisplayName</key>
8+
<string>SpeedySloth WatchKit App</string>
9+
<key>CFBundleExecutable</key>
10+
<string>$(EXECUTABLE_NAME)</string>
11+
<key>CFBundleIdentifier</key>
12+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
13+
<key>CFBundleInfoDictionaryVersion</key>
14+
<string>6.0</string>
15+
<key>CFBundleName</key>
16+
<string>$(PRODUCT_NAME)</string>
17+
<key>CFBundlePackageType</key>
18+
<string>APPL</string>
19+
<key>CFBundleShortVersionString</key>
20+
<string>1.0</string>
21+
<key>CFBundleSignature</key>
22+
<string>????</string>
23+
<key>CFBundleVersion</key>
24+
<string>1</string>
25+
<key>UISupportedInterfaceOrientations</key>
26+
<array>
27+
<string>UIInterfaceOrientationPortrait</string>
28+
<string>UIInterfaceOrientationPortraitUpsideDown</string>
29+
</array>
30+
<key>WKCompanionAppBundleIdentifier</key>
31+
<string>com.apple.SpeedySloth</string>
32+
<key>WKWatchKitApp</key>
33+
<true/>
34+
</dict>
35+
</plist>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "watch",
5+
"scale" : "2x"
6+
},
7+
{
8+
"idiom" : "watch",
9+
"scale" : "2x",
10+
"screen-width" : "<=145"
11+
},
12+
{
13+
"idiom" : "watch",
14+
"scale" : "2x",
15+
"screen-width" : ">145"
16+
}
17+
],
18+
"info" : {
19+
"version" : 1,
20+
"author" : "xcode"
21+
}
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"assets" : [
3+
{
4+
"idiom" : "watch",
5+
"filename" : "Circular.imageset",
6+
"role" : "circular"
7+
},
8+
{
9+
"idiom" : "watch",
10+
"filename" : "Modular.imageset",
11+
"role" : "modular"
12+
},
13+
{
14+
"idiom" : "watch",
15+
"filename" : "Utilitarian.imageset",
16+
"role" : "utilitarian"
17+
}
18+
],
19+
"info" : {
20+
"version" : 1,
21+
"author" : "xcode"
22+
}
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "watch",
5+
"scale" : "2x"
6+
},
7+
{
8+
"idiom" : "watch",
9+
"scale" : "2x",
10+
"screen-width" : "<=145"
11+
},
12+
{
13+
"idiom" : "watch",
14+
"scale" : "2x",
15+
"screen-width" : ">145"
16+
}
17+
],
18+
"info" : {
19+
"version" : 1,
20+
"author" : "xcode"
21+
}
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "watch",
5+
"scale" : "2x"
6+
},
7+
{
8+
"idiom" : "watch",
9+
"scale" : "2x",
10+
"screen-width" : "<=145"
11+
},
12+
{
13+
"idiom" : "watch",
14+
"scale" : "2x",
15+
"screen-width" : ">145"
16+
}
17+
],
18+
"info" : {
19+
"version" : 1,
20+
"author" : "xcode"
21+
}
22+
}

0 commit comments

Comments
 (0)