Introducing NaughtyKeyboard, a keyboard to break your apps

Earlier this week, Rémi shared a link to a github repository containing a bunch of weird strings you could use to test a web application. The given example was Twitter that gives you an internal server error when you try to post a tweet with one of those strings. Playing with the custom keyboard API of iOS was on my list but I had no idea what I could do with it until this repository. Last week I released a super-simple custom iOS keyboard to easily use these strings.

The API

func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
    let string = strings[indexPath.row]
    if let proxy  = textDocumentProxy as? UIKeyInput {
        proxy.insertText(string)
        proxy.insertText("\n")
    }
    tableView.deselectRowAtIndexPath(indexPath, animated: true)
}

The API is way simpler than I expected it to be. Everything happens in an UIViewController subclass from which you have access to a couple of objects and methods to fill the current text field with a string, go to the next available keyboard… Because all the strings are stored in a JSON file available in Minimaxir’s repository, the whole project took me less than an hour to be completed.

Open source is awesome

Naughty Keyboard Logo

When I started talking about this little project, it took a lunch break for my coworker Emile to open a pull-request with an icon for the application, based on The Noun Project. I was super happy to see this because I tried to do something myself but ended up rage-quitting Sketch. I’m not a very patient man.

Always be itching

I’ve always had trouble with the “always be shipping” motto. Most people (me included) have dozens of side projects sitting in Github Repositories. That’s why I’m more an “always be itching” kind of guy where most of my side projects start from a technology, a language or a new API I want to play with.

This little project ended up on last week’s iOSDevWeekly and now has more than 350 stars on Github, so I guess some people though it could be useful. I’ll try to make it better in the next few days, add a couple of features and make it prettier.