iOS Quick Tip – Viewing Core Data’s Generated SQL

If you are using Core Data – or any ORM or persistence framework, for that matter – it’s often handy to be able to view the generated SQL for your queries. Fortunately, Core Data makes this incredibly easy, and unlike some other ORMs, it doesn’t require crazy hacks or third party tools.

Click your project’s name in the Xcode toolbar:

Select ‘Edit Scheme’:

Go to the ‘Arguments’ tab and click the + button under ‘Arguments passed on launch’:

Enter ‘ 1’ as the argument:

Press OK, and run your app.

Notice all of the SQL statements that appear in Xcode’s output window.

Leave a Reply

Your email address will not be published. Required fields are marked *