ios 8 how to debug Custom Keyboard?

2020-06-03 05:17发布

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.

4条回答
三岁会撩人
2楼-- · 2020-06-03 05:42

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.

查看更多
小情绪 Triste *
3楼-- · 2020-06-03 05:46

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

查看更多
一夜七次
4楼-- · 2020-06-03 06:01

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

查看更多
叛逆
5楼-- · 2020-06-03 06:04

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.

查看更多
登录 后发表回答