Debug extensions for IOS 8 in Xcode

Extensions is a new feature introduced in IOS 8 and hence lots of developers wants to cash in the oppertunity to build apps that use extensions. While making keyboard extension app, i messed up myself  with a problem in which Xcode was not able to print values in console and neither breakpoints are working. In this post i am going to tell you that how we can debug our extension app using logs and breakpoints.
                             
                                            Since extension are provided inside a container app that is our main app. So to debug our extension first we need to build our main app and install it on simulator or device. This is shown in below screenshot where TestExtension is our main app and CustomKeyBoardDemo is our extension app.

Run container or main app
Run Main app or Container app

Now your main app or container app is running on simulator or device and you are able to change keyboards but you are not stopping by breakpoints you set in keyboard extensions view controllers.

Running main app on simulator
Running main app or container app on simulator

Now, select your extension as target. Shown in figure below

Selecting extension as our target
Selecting extension as our target

An option controller will be open by Xcode and it prompts you to select app with which you want your extension to be run.

Option controller opened by Xcode
Option controller opened by Xcode

Select TestExtension which is our main app from the option list and press Run

Select our main app or container app
Select our main app or container app

Now when you bring custom keyboard on screen, you will see console is printing NSLog’s and also breakpoints are working now.

Console printing NSLog's
Breakpoints in keyboard extension view controller
Breakpoints in keyboard extension view controller

So now following the above steps you will be able to debug extensions app.

Complete demo
Complete demo 

Hope you enjoyed the post.