This app serves as a host environment for a custom iOS keyboard extension.
The keyboard can have several horizontally scrollable pages showing several rows of buttons with letters or icons on them. Additionally there is a navigation bar with the obligatory switch-keyboard-button, a delete-button and a left / right button to scroll to the previous / next page.
iOS 10.2 or later
The buttons' content is loaded via a json-file, which must be part of the CustomKeyboard
target. Its format looks like this:
[{
"page1": {
"row1": [".", ".", ".", ".", ".", ".", ".", "."],
"row2": [".", ".", ".", ".", ".", ".", ".", "."],
"row3": [".", ".", ".", ".", ".", ".", ".", "."],
},
"page2": {
"row1": [".", ".", ".", ".", ".", ".", ".", "."],
"row2": [".", ".", ".", ".", ".", ".", ".", "."],
"row3": [".", ".", ".", ".", ".", ".", ".", "."],
},
}]
Custom features can be adjusted in the KeyboardSettings
class (in MyCustomFramework
):
- navigation bar height
- maximum number of pages (must be bigger than 0)
- maximum number of rows (must be bigger than 0)
- background color of the navigation bar
- background color of the scrollable keyboard part
- text color of the navigation bar buttons
- text color of the key buttons
To add the keyboard to your project follow these steps:
- Add a new target โ a custom keyboard extension - to your project and call it
CustomKeyboard
. Make sure to use that name, or the following step will have to be adapted. - Open your project in the Finder and replace the
CustomKeyboard
folder with the one from theHostApp
project; then copy and pasteMyCustomFramework
into the project folder as well. - Drag and drop
buttonTitles
from theCustomKeyboard
folder into the respecting folder in Xcode; then drag and dropMyCustomFramework.xcodeproj
from the Finder into your project. If the little arrow next to the framework name does not immediately show up, open and close XCode. - Add the framework to both targets,
YourApp
andCustomKeyboard
. - Finally
build
all of them in the following order:MyCustomFramework
,CustomKeyboard
,YourApp
. - Run your app and include the new keyboard in the device's settings.
All of MyCustomFramework
's classes and structs have originally been part of CustomKeyboard
, I however recently decided that I wanted to try and make the keyboard testable. Until now, it has not been possible to directly test keyboard extensions. Extracting the code into a separate framework circumvents this problem.
Having started the project under the assumption of not being able to test the code, it neither include tests (yet) nor has it been built with that goal in mind. Changing that will be the next step forward.