How to implement gyroscope?

I was some background on swift and I have done couple small apps. But I want to try to move to gaming scene.

I have a small game in mind and it involves gyroscope. I have divided the game into small pieces and I need a little help to lift off the ground.

What I would like to accomplish is to create 4 solid objects to create a box and put a small ball in it. Ball should behave like an objects inside an actuall box. when you tiltle the box, object should fall towards gravity. How should I get started?

Thanks