Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 <liulantao@gmail.com>
- Loading branch information
Showing
30 changed files
with
2,260 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
Sample code project: SpeedySloth: Using HealthKit to build a workout app for Apple Watch | ||
Version: 1.0 | ||
|
||
IMPORTANT: This Apple software is supplied to you by Apple | ||
Inc. ("Apple") in consideration of your agreement to the following | ||
terms, and your use, installation, modification or redistribution of | ||
this Apple software constitutes acceptance of these terms. If you do | ||
not agree with these terms, please do not use, install, modify or | ||
redistribute this Apple software. | ||
|
||
In consideration of your agreement to abide by the following terms, and | ||
subject to these terms, Apple grants you a personal, non-exclusive | ||
license, under Apple's copyrights in this original Apple software (the | ||
"Apple Software"), to use, reproduce, modify and redistribute the Apple | ||
Software, with or without modifications, in source and/or binary forms; | ||
provided that if you redistribute the Apple Software in its entirety and | ||
without modifications, you must retain this notice and the following | ||
text and disclaimers in all such redistributions of the Apple Software. | ||
Neither the name, trademarks, service marks or logos of Apple Inc. may | ||
be used to endorse or promote products derived from the Apple Software | ||
without specific prior written permission from Apple. Except as | ||
expressly stated in this notice, no other rights or licenses, express or | ||
implied, are granted by Apple herein, including but not limited to any | ||
patent rights that may be infringed by your derivative works or by other | ||
works in which the Apple Software may be incorporated. | ||
|
||
The Apple Software is provided by Apple on an "AS IS" basis. APPLE | ||
MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION | ||
THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS | ||
FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND | ||
OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. | ||
|
||
IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL | ||
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, | ||
MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED | ||
AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), | ||
STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE | ||
POSSIBILITY OF SUCH DAMAGE. | ||
|
||
Copyright (C) 2016 Apple Inc. All Rights Reserved. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# SpeedySloth: Using HealthKit to build a workout app for Apple Watch | ||
|
||
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. | ||
|
||
## Requirements | ||
|
||
### Build | ||
|
||
Xcode 8.0 or later; iOS 10.0 SDK, watchOS 3.0 SDK or later | ||
|
||
### Runtime | ||
|
||
iOS 10.0 or later, watchOS 3.0 or later | ||
|
||
Copyright (C) 2016 Apple Inc. All rights reserved. |
55 changes: 55 additions & 0 deletions
55
...oth/SpeedySloth/SpeedySloth WatchKit App/Assets.xcassets/AppIcon.appiconset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"size" : "24x24", | ||
"idiom" : "watch", | ||
"scale" : "2x", | ||
"role" : "notificationCenter", | ||
"subtype" : "38mm" | ||
}, | ||
{ | ||
"size" : "27.5x27.5", | ||
"idiom" : "watch", | ||
"scale" : "2x", | ||
"role" : "notificationCenter", | ||
"subtype" : "42mm" | ||
}, | ||
{ | ||
"size" : "29x29", | ||
"idiom" : "watch", | ||
"role" : "companionSettings", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"size" : "29x29", | ||
"idiom" : "watch", | ||
"role" : "companionSettings", | ||
"scale" : "3x" | ||
}, | ||
{ | ||
"size" : "40x40", | ||
"idiom" : "watch", | ||
"scale" : "2x", | ||
"role" : "appLauncher", | ||
"subtype" : "38mm" | ||
}, | ||
{ | ||
"size" : "86x86", | ||
"idiom" : "watch", | ||
"scale" : "2x", | ||
"role" : "quickLook", | ||
"subtype" : "38mm" | ||
}, | ||
{ | ||
"size" : "98x98", | ||
"idiom" : "watch", | ||
"scale" : "2x", | ||
"role" : "quickLook", | ||
"subtype" : "42mm" | ||
} | ||
], | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
119 changes: 119 additions & 0 deletions
119
SpeedySloth/SpeedySloth/SpeedySloth WatchKit App/Base.lproj/Interface.storyboard
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<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"> | ||
<dependencies> | ||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11103.5"/> | ||
<plugIn identifier="com.apple.InterfaceBuilder.IBWatchKitPlugin" version="11055.3"/> | ||
</dependencies> | ||
<scenes> | ||
<!--ConfigurationInterfaceController--> | ||
<scene sceneID="aou-V4-d1y"> | ||
<objects> | ||
<controller identifier="ConfigurationInterfaceController" id="AgC-eL-Hgc" customClass="ConfigurationInterfaceController" customModule="SpeedySloth_WatchKit_Extension"> | ||
<items> | ||
<label alignment="left" text="Activity Type" id="JbE-ls-T0G"> | ||
<fontDescription key="font" style="UICTFontTextStyleCaption2"/> | ||
</label> | ||
<picker height="38" alignment="left" focusStyle="stack" indicatorMode="shownWhileFocused" id="Cvl-Np-0ix"> | ||
<connections> | ||
<action selector="activityTypePickerSelectedItemChangedWithValue:" destination="AgC-eL-Hgc" id="7sX-Cj-WaB"/> | ||
</connections> | ||
</picker> | ||
<label alignment="left" text="Location Type" id="w0Y-gV-pKv"> | ||
<fontDescription key="font" style="UICTFontTextStyleCaption2"/> | ||
</label> | ||
<picker height="38" alignment="left" focusStyle="stack" indicatorMode="shownWhileFocused" id="yQ9-Eh-8Xr"/> | ||
<button width="1" alignment="left" verticalAlignment="bottom" title="Start" id="wLU-pX-ZjH"> | ||
<connections> | ||
<action selector="didTapStartButton" destination="AgC-eL-Hgc" id="4LV-Ng-rNA"/> | ||
</connections> | ||
</button> | ||
</items> | ||
<connections> | ||
<outlet property="activityTypePicker" destination="Cvl-Np-0ix" id="vlU-Fd-CBb"/> | ||
<outlet property="locationTypePicker" destination="yQ9-Eh-8Xr" id="lei-VH-pKM"/> | ||
</connections> | ||
</controller> | ||
</objects> | ||
<point key="canvasLocation" x="171" y="141"/> | ||
</scene> | ||
<!--WorkoutInterfaceController--> | ||
<scene sceneID="n0q-AO-fFK"> | ||
<objects> | ||
<controller identifier="WorkoutInterfaceController" id="3AD-3g-W6O" customClass="WorkoutInterfaceController" customModule="SpeedySloth_WatchKit_Extension"> | ||
<items> | ||
<label alignment="left" text="Label" id="ADM-9Z-RsX"> | ||
<color key="textColor" red="1" green="0.97880674710000004" blue="0.13324607359999999" alpha="1" colorSpace="calibratedRGB"/> | ||
</label> | ||
<label alignment="left" text="Label" id="OIZ-b9-Zi2"> | ||
<color key="textColor" red="1" green="0.041046944600000003" blue="0.0" alpha="1" colorSpace="calibratedRGB"/> | ||
</label> | ||
<label alignment="left" text="Label" id="Eao-ZG-tZX"> | ||
<color key="textColor" red="0.0" green="0.56638695100000003" blue="1" alpha="1" colorSpace="calibratedRGB"/> | ||
</label> | ||
<label width="136" alignment="left" alpha="0.0" text="Marker Saved!" textAlignment="right" id="oVG-L9-p0W"> | ||
<color key="textColor" red="1" green="1" blue="0.0" alpha="1" colorSpace="calibratedRGB"/> | ||
</label> | ||
<group width="1" alignment="left" id="7cE-B0-MCY"> | ||
<items> | ||
<button width="0.5" alignment="left" title="Pause" id="0xt-7N-diW"> | ||
<connections> | ||
<action selector="didTapPauseResumeButton" destination="3AD-3g-W6O" id="4MJ-Sw-PnG"/> | ||
</connections> | ||
</button> | ||
<button width="0.5" alignment="left" title="Marker" id="Pnp-Yb-J7c"> | ||
<connections> | ||
<action selector="didTapMarkerButton" destination="3AD-3g-W6O" id="vcd-Gk-GC5"/> | ||
</connections> | ||
</button> | ||
</items> | ||
</group> | ||
<button width="1" alignment="right" verticalAlignment="bottom" title="Stop" id="bgZ-vR-fSL"> | ||
<connections> | ||
<action selector="didTapStopButton" destination="3AD-3g-W6O" id="eGL-Yc-XKR"/> | ||
</connections> | ||
</button> | ||
</items> | ||
<connections> | ||
<outlet property="caloriesLabel" destination="OIZ-b9-Zi2" id="RPQ-VI-hyp"/> | ||
<outlet property="distanceLabel" destination="Eao-ZG-tZX" id="Jhc-Sb-uhp"/> | ||
<outlet property="durationLabel" destination="ADM-9Z-RsX" id="eke-aD-t4Y"/> | ||
<outlet property="markerLabel" destination="oVG-L9-p0W" id="4O7-ts-UvL"/> | ||
<outlet property="pauseResumeButton" destination="0xt-7N-diW" id="C9y-rl-7ER"/> | ||
</connections> | ||
</controller> | ||
</objects> | ||
<point key="canvasLocation" x="375" y="152"/> | ||
</scene> | ||
<!--SummaryInterfaceController--> | ||
<scene sceneID="tRq-Ml-cM9"> | ||
<objects> | ||
<controller identifier="SummaryInterfaceController" id="JTE-42-caD" customClass="SummaryInterfaceController" customModule="SpeedySloth_WatchKit_Extension"> | ||
<items> | ||
<label alignment="left" text="Label" id="cl2-ui-nNn"/> | ||
<label alignment="left" text="Label" id="Kt7-je-LHa"> | ||
<color key="textColor" red="1" green="0.97880674707302084" blue="0.13324607364832664" alpha="1" colorSpace="calibratedRGB"/> | ||
</label> | ||
<label alignment="left" text="Label" id="d7l-ho-0Yo"> | ||
<color key="textColor" red="1" green="0.041046944598614132" blue="0.0" alpha="1" colorSpace="calibratedRGB"/> | ||
</label> | ||
<label alignment="left" text="Label" id="Wng-ib-fyp"> | ||
<color key="textColor" red="0.0" green="0.56638695098710379" blue="1" alpha="1" colorSpace="calibratedRGB"/> | ||
</label> | ||
<button width="1" alignment="left" verticalAlignment="bottom" title="Done" id="s3l-fi-rwP"> | ||
<connections> | ||
<action selector="didTapDoneButton" destination="JTE-42-caD" id="Yea-GW-2eW"/> | ||
</connections> | ||
</button> | ||
</items> | ||
<connections> | ||
<outlet property="caloriesLabel" destination="d7l-ho-0Yo" id="xaX-zb-yfm"/> | ||
<outlet property="distanceLabel" destination="Wng-ib-fyp" id="u0g-FN-J8a"/> | ||
<outlet property="durationLabel" destination="Kt7-je-LHa" id="2RK-GS-5yy"/> | ||
<outlet property="workoutLabel" destination="cl2-ui-nNn" id="C4V-Te-6qe"/> | ||
</connections> | ||
</controller> | ||
</objects> | ||
<point key="canvasLocation" x="580" y="152"/> | ||
</scene> | ||
</scenes> | ||
</document> |
35 changes: 35 additions & 0 deletions
35
SpeedySloth/SpeedySloth/SpeedySloth WatchKit App/Info.plist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>CFBundleDevelopmentRegion</key> | ||
<string>en</string> | ||
<key>CFBundleDisplayName</key> | ||
<string>SpeedySloth WatchKit App</string> | ||
<key>CFBundleExecutable</key> | ||
<string>$(EXECUTABLE_NAME)</string> | ||
<key>CFBundleIdentifier</key> | ||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> | ||
<key>CFBundleInfoDictionaryVersion</key> | ||
<string>6.0</string> | ||
<key>CFBundleName</key> | ||
<string>$(PRODUCT_NAME)</string> | ||
<key>CFBundlePackageType</key> | ||
<string>APPL</string> | ||
<key>CFBundleShortVersionString</key> | ||
<string>1.0</string> | ||
<key>CFBundleSignature</key> | ||
<string>????</string> | ||
<key>CFBundleVersion</key> | ||
<string>1</string> | ||
<key>UISupportedInterfaceOrientations</key> | ||
<array> | ||
<string>UIInterfaceOrientationPortrait</string> | ||
<string>UIInterfaceOrientationPortraitUpsideDown</string> | ||
</array> | ||
<key>WKCompanionAppBundleIdentifier</key> | ||
<string>com.apple.SpeedySloth</string> | ||
<key>WKWatchKitApp</key> | ||
<true/> | ||
</dict> | ||
</plist> |
22 changes: 22 additions & 0 deletions
22
...it Extension/Assets.xcassets/Complication.complicationset/Circular.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "watch", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "watch", | ||
"scale" : "2x", | ||
"screen-width" : "<=145" | ||
}, | ||
{ | ||
"idiom" : "watch", | ||
"scale" : "2x", | ||
"screen-width" : ">145" | ||
} | ||
], | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...SpeedySloth WatchKit Extension/Assets.xcassets/Complication.complicationset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"assets" : [ | ||
{ | ||
"idiom" : "watch", | ||
"filename" : "Circular.imageset", | ||
"role" : "circular" | ||
}, | ||
{ | ||
"idiom" : "watch", | ||
"filename" : "Modular.imageset", | ||
"role" : "modular" | ||
}, | ||
{ | ||
"idiom" : "watch", | ||
"filename" : "Utilitarian.imageset", | ||
"role" : "utilitarian" | ||
} | ||
], | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...Kit Extension/Assets.xcassets/Complication.complicationset/Modular.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "watch", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "watch", | ||
"scale" : "2x", | ||
"screen-width" : "<=145" | ||
}, | ||
{ | ||
"idiom" : "watch", | ||
"scale" : "2x", | ||
"screen-width" : ">145" | ||
} | ||
], | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...Extension/Assets.xcassets/Complication.complicationset/Utilitarian.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "watch", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "watch", | ||
"scale" : "2x", | ||
"screen-width" : "<=145" | ||
}, | ||
{ | ||
"idiom" : "watch", | ||
"scale" : "2x", | ||
"screen-width" : ">145" | ||
} | ||
], | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
Oops, something went wrong.