Мой "Helloworld" CoreMotion:
1) Добавить CoreMotion.framework
2) в файле .h:
#import <CoreMotion/CoreMotion.h>
3) в файле .m:
CMMotionManager *myMotionManager= [[CMMotionManager alloc] init];
myMotionManager.deviceMotionUpdateInterval = 1/60;
[myMotionManager startDeviceMotionUpdatesUsingReferenceFrame:CMAttitudeReferenceFrameXMagneticNorthZVertical toQueue:[NSOperationQueue currentQueue] withHandler:^(CMDeviceMotion *motion, NSError *error) {
double x = myMotionManager.deviceMotion.magneticField.field.x;
double y = myMotionManager.deviceMotion.magneticField.field.y;
double z = myMotionManager.deviceMotion.magneticField.field.z;
NSLog(@"Strength of Earth's magnetic field= %8.2f",sqrt(x*x+y*y+z*z));
myLabel.text = [NSString stringWithFormat:@"%8.2f", sqrt(x*x+y*y+z*z)];
}];