Can one be simulated by periodicly syncing with GPS and in the meen while working with the accelerometer? I know for example that the N95 accelerometer is invarient to rotation on the Y axis (while beeing face up/down).

+2  A: 

iPhone doesn't have a built in compass; but there is one created in software. It's called Compass Free, and unsurprisingly perhaps, it's free.


Extra info: The IPHONE 1 did not have GPS or compass.

+3  A: 

The original iPhone and the iPhone 3G use GPS to calculate the heading, however the iPhone 3GS now has a 3-dimensional magnetometer compass in it.

This can only be done taking two GPS coordinates (while moving) and determining the direction from point A to B.

Nick Bedford
The heading from GPS only indicates what direction the phone is moving and only works if it is moving. It doesn't tell you what direction it is facing like a compass does. But it may be better than nothing if it meets your needs.
Yeah I know. Should have mentioned that.
Nick Bedford