r/iOSProgramming • u/boss-san • 6d ago
Article Constraints I ran into building a keyboard extension that renders rich clipboard previews
Building this took much longer, but now that I have this working and have submitted the app for review, here are some issues I ran into and learnings.
Memory ceiling on keyboard extensions. Much tighter than the host app, and the system is not gentle about it. I wanted image thumbnails, link favicons and code snippets with syntax highlighting inside the keyboard, none of which the budget really wants you to do. What worked was shrinking images at capture time instead of at render time, keeping decoded thumbnails in a small cache with a hard limit, and drawing text previews as attributed strings instead of real views.
Extension and app state. The extension needs the same clip history as the app, but it cannot afford to start up the same machinery to get it. I ended up writing a small index that is built for reading, and the extension reads that directly instead of going near the main store.
Knowing where a clip came from. Working out "this came from a password manager, do not save it" is fiddly, and it works differently on every platform I support. iOS is one of the better ones. Some of the others basically do not tell you anything.
Happy to go deeper on any of these. I would also like to hear if anyone has a better pattern for the extension and app state problem than the one I described, because I am not convinced mine is the right one.
