Getting started: Ios configuration
Prepare your project for Apple Health.
Ios configuration
On root folder run:
flutter pub get
On ios/Podfile add the following
platform :ios, '13.0'
On ios folder run:
pod install
Open the ios folder with Xcode
Add HealthKit capability to your Xcode project:
- Open your project in Xcode.
- Click on your project file (most cases is Runner) in the Project Navigator.
- Click on the "Signing and capabilities" tab.
- Click on the "+ Capability" button and select "HealthKit" from the list.
- Check the "Background delivery" option
- Click on the "+ Capability" button and select "Background Modes" from the list.
- Check the "Background fetch" option
Add HealthKit framework to your Xcode project:
- Open your project in Xcode.
- Click on your project file (most cases is Runner) in the Project Navigator.
- Click on the "Build Phases" tab.
- Click on the "+" button under the "Link Binary With Libraries" section and select "HealthKit.framework" from the list.
Declare the privacy permissions used by this SDK. You will need to include the NSHealthShareUsageDescription and NSHealthUpdateUsageDescription keys in your app's Info.plist file.
These keys provide a description of why your app needs to access HealthKit data and will be displayed to the user in the permission request dialog.
- Open ios folder
- Open Runner folder
- Add the following to Info.plist
<key>NSHealthShareUsageDescription</key>
<string>This app requires access to your health and fitness data in order to track your workouts and activity levels.</string>
<key>NSHealthUpdateUsageDescription</key>
<string>This app requires permission to write workout data to HealthKit.</string>