<!--
{
  "availability" : [
    "iOS: 5.0.0 -",
    "iPadOS: 5.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.15.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreMotion",
  "identifier" : "/documentation/CoreMotion/CMMagnetometerData/magneticField",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "Core Motion"
    ],
    "preciseIdentifier" : "c:objc(cs)CMMagnetometerData(py)magneticField"
  },
  "title" : "magneticField"
}
-->

# magneticField

Returns the magnetic field measured by the magnetometer.

```
var magneticField: CMMagneticField { get }
```

## Discussion

The value of this property is the total magnetic field observed by the device which is equal to the Earth’s geomagnetic field plus bias introduced from the device itself and its surroundings.

This is the “raw” magnetic-field value, unlike the calibrated value of the [`magneticField`](/documentation/CoreMotion/CMDeviceMotion/magneticField) property of [`CMDeviceMotion`](/documentation/CoreMotion/CMDeviceMotion) which filters out the bias introduced by the device and, in some cases, its surrounding fields.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)