Menu

Building a snippet keyboard for iPhone and a paste picker for the Mac menu bar
📰

Building a snippet keyboard for iPhone and a paste picker for the Mac menu bar

DEV Community: swift·Kenneth Fang·about 18 hours ago
#hBA9MMK2
#devtoswift#devto#dev#keyboard#cutling
Long article (612 words) — no AI summary yet.
Reading 0:00
15s threshold

I make Cutling , an app that keeps the text you type again and again (your address, bank details, an email signature, the reply you send every week) and pastes it with one tap. On iPhone and iPad it's a keyboard you switch to in any app; on the Mac it sits in the menu bar and Shift-Command-V opens a picker at your cursor. The code is open source under GPL-3.0 ( GitHub ). Here's how the two halves work, and the platform corners I ran into.

On iPhone: a keyboard extension that inserts text

A custom keyboard gets a textDocumentProxy , and inserting a snippet is one call: proxy.insertText(value) . Images are different, because a keyboard can't insert an image into a text field. Cutling puts the image on UIPasteboard.general with its real type (it reads the type from the data with CGImageSourceGetType , so a GIF stays a GIF) and you paste it.

That pasteboard write is why the keyboard asks for Full Access ( RequestsOpenAccess in its Info.plist).…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.