How I built Picknick, on-device photo search for iOS
Picknick is a Swift library that searches an iPhone's photo library by meaning, text, place and people. You type "dog on a beach" and it finds the photos. Nothing leaves the device. It has no third-party dependencies, and the code is public at github.com/ponikar/picknick.ios.
I wrote the architecture in September. The repo history runs from 7 to 9 November, 26 commits, built with Claude Code agents working in parallel. This is what I decided, what I measured, and what I changed along the way.
Privacy by structure
The rule was that no photo data leaves the phone. I wanted that to be a property of the code, not a promise, so the package has no network code at all. I searched it for URLSession and found none.
The one way out is a broker module. A remote AI can ask a question, the broker runs the search and builds a text summary of the matches, you review it, and only then does your app send it. The broker never holds pixels or photo ids, and the sending is the app's job, not the library's.
How a photo becomes searchable
The library is ten small modules that only talk through a shared core of protocols. That is what made it possible to build them in parallel.
The indexer scans the library through PhotoKit and hands each photo to the extractors. Running it again only processes photos that are new or changed, so it is safe to call whenever the app opens.
Why one embedding model
Apple's Vision framework can compare two photos, but its fingerprint is not aligned with text, so it cannot answer "red bike". MobileCLIP puts text and photos in the same space, so it can.
Meaning alone misses things, though. The words on a receipt or the name of a city are not something an embedding is good at, so Vision labels, text inside photos and place names each cover one of those gaps.
How a query is answered
The first version merged the four signals by rank. It looked fine until I typed "vietnam" into a test app and got random photos back. Ranking only says which photo is best, never whether any photo is good, so it always returns something.
So I changed what a score means. Each signal now gives a probability. Meaning scores come from a logistic fit of the MobileCLIP similarity on 298 labelled photos. Labels use Vision's confidence. An exact text or place hit scores 0.99. They combine with a noisy-OR, and a search takes a top N and a minimum probability.
The query is checked for place names, longest phrase first, so "new york" is not read as New South Wales. Names of people you have labelled are picked out the same way.
Well-known places answer from GPS only, so "vietnam" with no photos there now returns nothing. It is not perfect. A nonsense word like "xqzvbt" can still score around 0.9, and the probabilities were calibrated on those 298 photos, so a real library may score differently.
Building it in parallel
I split the build along module boundaries. Five of the six pieces did not depend on each other: the CLIP encoder, Vision labels, Vision text, search and place names. Agents built them at the same time, with at most three running at once. Each reviewed its own code, then everything merged into one branch before the next round started. The broker had to wait, because it needs search to exist first.
Evals before opinions
I did not want to judge search by trying a few queries. So I built an eval first: an iOS app that loads 298 COCO photos (each with five human captions), 8 screenshots with known text and 20 photos given GPS in 9 cities into the simulator, indexes them with the real models, and runs 67 queries. Each kind of query has its own pass rule. Meaning needs 3 of the top 5 to be relevant, text needs the right screenshot at rank 1, places need exactly the tagged photos, and gibberish must return nothing.
On the first run about 4 of the top 5 results were right for meaning searches. It also found real bugs. A similarity floor of 0.2 dropped about half the relevant hits, so I lowered it to 0.12. Text search now requires every query word. And "new york" matched New South Wales until places were matched longest phrase first. One limit: relevance is judged by caption keywords, so a correct photo whose captions use another word counts as a miss.
On speed, the simulator indexed about 0.6 seconds per photo, roughly 10 minutes per 1,000 photos. That run skipped Vision labels, which do not run in the simulator, so I treat it as a rough guide and not a phone benchmark.
React Native
I work in React Native, so I wrapped the library with Nitro Modules in `lib/react-native`. The API is small: configure, requestPhotoAccess, indexLibrary with a progress callback, getStatus, and search(query, { topN, minimumProbability }). It is iOS only and was tested with React Native 0.88 and Nitro 0.37. The example app has a self-test that checks ordering, top N, the minimum probability and a query with no match.
Searching for people
The next gap was "darshan having coffee at cafe", which returned any coffee. Nothing in the index knows who is in a photo, and the Photos app's People names have no public API. So you name a face once, and the name spreads to faces that look close enough. I wrote the spec first, with numbered requirements and an edge-case table, before any code.
I had decided to use only Apple's built-in APIs, with no custom face model. The first accuracy test said that was a problem. On 200 public photos of 20 people, matching each face to the nearest named one was right about half the time. Random guessing gets 5%. At one point an agent started adding a face-recognition model. I had agreed not to ship one, so we stopped it and tried fixes inside Apple's APIs.
A wider crop around the face did most of the work: right 79% of the time with one named photo per person, and 92% with five. Then a clear-winner rule. A face is named automatically only if its nearest named face is within a cutoff and every other person is at least 10% farther away. At a cutoff of 0.72 it names 58% of faces and gets 97% of those right.
What it does not do yet
- It has been tested on macOS, the iOS Simulator and one iPhone.
- The match probabilities were calibrated on 298 photos, and nonsense words can still score high.
- Person naming was measured on 200 photos of 20 people, not on a real library.
- The React Native binding is iOS only.