I've been using gravity() during a scene's setup to establish the starting position of the device. It works great on my iPad Air. My iPhone 5, however, doesn't seem to get any values from gravity() when run during setup.
To test this, check out the following code: https://gist.github.com/andrewschmidt/8293953
Run on my iPad Air, tilted mostly vertical, this outputs:
Run on my iPhone 5, in any position:
It's worth noting that in my actual script, the gravity() call made after the scene has begun looping works fine on the iPhone. It's only in setup that it doesn't return anything.
I don't know which is the intended behavior, but it can't be both!
And I'm back a couple minutes later with a discovery.
I added a hack-y bit of code—I stuck the gravity() call in a WHILE loop that doesn't end until it gets values different than zero.
This mostly solved the problem on my iPhone. Based on just how it feels to use gravity() to move a rect around, it seems like the accelerometer takes a second or two after it begins returning values to return correct values. I wouldn't expect Pythonista to do anything about that—it's just something devs will have to be aware of.
In summary: Looks like the iPhone 5 is a bit slower about either getting gravity() up and running, or getting values from the system's accelerometer. A little too slow to get any information before a scene has finished with setup.