Check out How to add UI Automation test to existing Xcode project by JR. Here is an excerpt:
Create a new project.
Add a new target by hitting the ‘+’ sign near the bottom.
Add iOS UI Testing Bundle
Edit your scheme
Confirm at testing bundle was added
Open up your test
And insert a break point
Run your test. Hit record and Xcode will record your application press.