13

I have successfully created a Custom Keyboard with Swift on iOS 8 simulator.

Although it worked well, but I could not debug it. It is a contained target and was installed through Settings->General. Placing a bookmark in XCode not work.

Andrew
  • 15,357
  • 6
  • 66
  • 101
Chula
  • 131
  • 1
  • 3
  • 1
    I think debbuging extensions in xcode is just buggy and broken. I had also problems debbuging a widgtet (NSLog not working, attaching process very tideous, etc.). I think your best bet is to wait on a new beta version and hope they fix it or wait for the final release. – gallileo Jul 03 '14 at 14:43
  • Dunno about everyone but my custom keyboard works in simulator, but not on device. Xcode 6 beta 3, iOS 8 beta 3. I can select the keyboard on device, but it does not show the keyboard selection button that shows on simulator. – Jonny Jul 08 '14 at 10:10
  • possible duplicate of [How to debug iOS 8 extensions with NSLog?](http://stackoverflow.com/questions/24031612/how-to-debug-ios-8-extensions-with-nslog) – Andrew Jul 09 '14 at 03:06

4 Answers4

23

I am able to debug a custom keyboard using the simulator via Xcode 6.

  1. Select the keyboard (and not it's container) as the scheme. Change scheme

  2. "Run" and then select on of the apps on your simulator to debug the extension with.

Run your app

james_womack
  • 10,028
  • 6
  • 55
  • 74
  • 1
    For some reason I cannot see my Keyboard Extensions as one of apps to run. I can see the host (container app) and the Today extension, but not my keyboard extension. It runs fine - I can add it as a custom keyboard, but I cannot debug it. – er0 Oct 09 '14 at 19:27
  • @er0 do you have a target for the extension? Have you configured your plist correctly? – james_womack Oct 09 '14 at 20:20
  • I still cannot see it in the apps to run - but when I run the container app and activate my custom keyboard, I can debug it. So all is well. – er0 Oct 10 '14 at 04:54
4

It seems as of now apple didn't get support for debugging extension into simulator. I was having same issue but I observe that We can debug code if we execute application into device as below.

1) Choose your Keyboard extension target.

2) Go to Edit Scheme.

3) In info tab select your Executable from drop down and check the option "Debug extensions and XPC services".

Still several problems are there like we can't see output of NSLog but you can check the value of variables same as before or I suggest you to check this link It may work for displaying NSLog output KeyboardViewController NSLog IOS 8.

Community
  • 1
  • 1
imDeveloper
  • 804
  • 1
  • 8
  • 16
  • I do not have physical device with iOS 8 beta installed yet. I will try it when I have one. – Chula Jul 16 '14 at 08:13
4

Apple has reported this problem as a know issue in Xcode 6.1 release notes:

Localization and Keyboard settings, including 3rd party keyboards, are not correctly honored by Safari, Maps, and developer apps in the iOS 8.1 Simulator. [NSLocale currentLocale] returns en_US and only the English and Emoji keyboards are available. (18418630, 18512161)

I'm using Xcode 6.1.1 and seems that it still hasn't been solved but I've discovered a workaround. You should follow this steps:

  1. Open Xcode and in its menu bar click into Xcode > Open Developer Tool > iOS Simulator

  2. Now into iOS Simulator menu bar go to Hardware > keyboard and check if "Connect Hardware Keyboard" is enable. If it is, click it to disable and quit iOS Simulator

  3. Then go back to Xcode and make sure that keyboard is selected as scheme

  4. Click into run button or press Product > Run to build and run you application and in the "Choose an app to run" menu choose Today

  5. When iOS Simulator starts, go to Settings > General > Keyboard > Keyboards > Add New Keyboard and select your own and then press in your keyboard command + shift + H to back to the homescreen

  6. Finally open Calendar app and press the magnifying glass icon, the keyboard will appear and you only need to hold the globe button to show the list of enabled keyboards and select yours Note that it's important to try your keyboard in the Calendar app because in most applications it doesn't work or it has an unexpected behavior

If the keyboard still doesn't appear:

  • remove the file com.apple.iphonesimulator.plist from ~/Libray/Preferences/
  • In iOS Simulator menu bar click into iOS Simulator > Reset Content and Settings...

More info about keyboard debugging and development here

Alex Guerrero
  • 2,109
  • 1
  • 19
  • 28
0

After searching and investigating this, I've found the best solution to be to install and use Reveal. It helps you visualise the custom keyboard like the debug hierarchy view and shows various other measures.

tanosaur
  • 9
  • 3