Book Image

Application Development with Swift

By : Hossam Ghareeb
Book Image

Application Development with Swift

By: Hossam Ghareeb

Overview of this book

Table of Contents (14 chapters)

Getting started with HealthKit


To get started with HealthKit, we will create a demo that will teach you how to request permission from the user to access his data from the Health app, read and format this information to make it readable for the user, and write info in the Health app. Now, go to Xcode and create a new project with a single view template, and make sure that Swift is selected as the project language.

Configuring the Xcode project

To configure our project using HealthKit, you have to first enable the HealthKit capabilities. To do this, select your target on Xcode, and click on the Capabilities tab. Then, enable HealthKit in the list by switching it ON; check the following screenshot:

After enabling the HealthKit capabilities, HealthKit will be added to the list of required device capabilities. This will prevent users from installing your app on devices that don't support HealthKit, such as iPad. But what if HealthKit is not your main idea or the main operation in your app? In this...