Initializes a new device object.


init(name: String?, manufacturer: String?, model: String?, hardwareVersion: String?, firmwareVersion: String?, softwareVersion: String?, localIdentifier: String?, udiDeviceIdentifier UDIDeviceIdentifier: String?)



A string containing the user-facing name for the device.


A string containing the device manufacturer’s name.


A string containing the device’s model name.


A string identifying the hardware version for the device.


A string identifying the version of the firmware that is installed on the device.


A string identifying the version of the software that is running on the device.


A string that uniquely identifies the device. Each health and fitness peripheral should have a separate local identifier for each iOS device it connects to. For example, a heart-rate monitor would have a different identifier when connected to Apple Watch than when connected to iPhone.


If the device object represents a medical device, use the device identifier portion of the Food and Drug Administration Unique Device Identifier (UDI). If the device does not have a UDI, pass nil.

Return Value

A newly initialized device object that encapsulates the provided data.


Use this method to create a device object representing an arbitrary piece of hardware. In general, the values for these parameters should match the information broadcasted by the hardware.

When creating device objects for use in queries, only pass in values for the parameters you need for your search. When used in a predicate, HealthKit finds all devices that match the non-nil parameters. This gives you a great deal of control when it comes to fine-tuning your search. For example, setting the localIdentifier and the firmwareVersion parameters lets you query for all the samples generated by a specific device running a specific version of the firmware. Just setting the manufacturer and model casts a much broader net. For more information on querying for device-specific samples, see HKPredicateKeyPathDevice.

When creating devices for new samples, it is best to provide values for as many parameters as you can. Even if you aren’t interest in a particular parameter, other apps may use it in their queries. More importantly, your app may need to use it in the future.

See Also

Creating Device Objects

class func local() -> HKDevice

returns a device object that represents the current device.