fabric_stash

Fabric Catalog

A voice-first fabric catalog for iPhone, iPad and Mac. Hold fabric up to the camera, describe it out loud, and on-device AI fills out the profile. Everything syncs through iCloud.

Everything runs on the device: Vision, Speech and Apple’s Foundation Models. No data leaves the phone except your own iCloud sync.

How it works

Step What does it Where
Find the fabric, clip a square swatch Vision foreground mask → largest inscribed square FabricKit/.../SwatchExtractor.swift
Color tags k-means on the swatch → plain color names ColorAnalyzer.swift, RGB.swift
Pattern hints Vision image classifier labels PatternAnalyzer.swift
Speech → text, voice commands SpeechAnalyzer + SpeechTranscriber FabricStash/Voice/SpeechListener.swift
Yards, width, fiber from what she said Deterministic parsing TranscriptParser.swift
Fill out the profile Foundation Models (on-device, sees the swatch image) with guided generation ProfileGenerator.swift
Hands-free flow State machine: aim → describe → review → save AddFabricCoordinator.swift
“Hey Siri, add fabric to Fabric Catalog” App Intents / App Shortcuts FabricIntents.swift
Sync and sharing Core Data + NSPersistentCloudKitContainer (private + shared CloudKit databases) StashStore.swift, StashSharing.swift

The profile streams in: the review screen appears right away and fields fill in live as the model writes them (Foundation Models streamResponse, about 50 updates over ~3 seconds).

Designer, collection, manufacturer, source and planned project are only kept if they were actually said or printed on the selvage, so the model can’t invent them. When the model and her words disagree, her words win: a spoken pattern, fiber or yardage always beats the model’s guess.

Designers

Each fabric can have a designer, collection and manufacturer (all optional; blank means “no designer”). They’re filled from what she says (“Heather Ross, Far Far Away, Windham”) and from text read off the selvage when it’s in the photo. The app knows about 175 designers and 85 fabric companies (FabricKit/Sources/FabricKit/Resources/fabric-brands.json, easy to add to) and learns every designer already in her stash. Those names also help speech recognition hear them correctly. Sort → Designer groups the catalog by designer.

Tap the microphone on the catalog and say what you want: “blue florals”, “anything for pajamas”, “maroon checked”. Search understands everyday color words (grey, ivory, burgundy, sage…) and pattern words (checked, polka dot, flowery).

Ask Siri about the stash

Siri reads these answers aloud without opening the app:

Answers come from StashAnswer in FabricKit (deterministic and unit-tested), so amounts are always exact.

Voice commands

Teaching it in the app

Project layout

One-time setup in Xcode

  1. Make sure your Apple ID is signed in (Xcode → Settings → Accounts). The team (T9RGDVM85M, same as Nerts) is already set on both targets with automatic signing, so Xcode creates the provisioning profiles on the first device build.
  2. If com.remor.fabricstash is taken, change the bundle ID and update the container name iCloud.com.remor.fabricstash in both entitlements files.
  3. Under the iCloud capability, make sure the container is checked (Xcode creates it in your developer account).
  4. Confirm the App Groups capability shows group.com.remor.fabricstash on both targets.
  5. Run on a real iPhone. The simulator has no camera or speech model; it falls back to “Choose Photo” and typing.

Apple Intelligence must be on (Settings → Apple Intelligence & Siri) for the AI fill-in. Without it the app still works using measured colors and parsed facts.

TestFlight

She uses TestFlight builds only; development builds run on your own phone. The two use separate iCloud databases. Builds run from Xcode use CloudKit’s Development environment, and TestFlight uses Production, so fabric added in one never shows up in the other.

Once, before the first Production deploy: if any earlier build (the SwiftData versions, before stashes) ran signed into iCloud, the Development environment holds record shapes the app no longer uses (fabric with a photoData field, capture logs inside fabric). Deploying those would make them permanent. In CloudKit Console, Reset Development Environment first, then do the steps below.

Before her first build, and again after any change to the model (StashModel.swift):

  1. Run a development build on your phone, save one fabric and share one stash (to create the share records too). That creates or updates the schema in the Development environment.
  2. In CloudKit Console → container iCloud.com.remor.fabricstash → Deploy Schema Changes…, deploy it to Production.

Production schema changes are additive only: fields and entities can be added but never renamed or removed. Treat Stash and Fabric fields as permanent once deployed (CaptureRecord is local-only, so it isn’t in CloudKit). The model is defined in code (StashModel.swift), its header lists the rules, and DataModelTests.modelFollowsCloudKitRules fails the build’s tests if a change would break CloudKit.

Uploading: Product → Archive, then in the Organizer choose Distribute App → TestFlight & App Store. Leave “Manage Version and Build Number” on so each upload gets a new build number. The app declares no non-exempt encryption (ITSAppUsesNonExemptEncryption), so TestFlight won’t ask the export-compliance question. Add her as a tester in App Store Connect. An internal tester (a member of your team) gets builds without Beta App Review.

Capture logs record the app version and build number (e.g. 1.0 (3)). Tagging the commit you archived, e.g. git tag testflight-3, lets you match a Development Export to the exact code later.

Device logs in Console

With the phone plugged in (or on the same Wi-Fi with “Connect via network”), open Console.app, select the phone, click Start, and search subsystem:com.remor.fabricstash. Categories:

Category What it logs
add-fabric photo analysis (fabric found, colors, pattern, selvage), AI timings, saves
camera camera start (and depth source), auto-capture triggers and why it isn’t capturing (face, not flat, distance), photo timing, interruptions (calls, heat, other apps)
speech language, audio route, speech-model download, recognition stopping
ai model failures
look-alike how many fabrics were compared and the nearest distance
sync every iCloud setup/upload/download, with errors
export exports and their failures

Errors (problem) are also held in memory and attached to the next fabric’s capture log, so the same failures show up in a Development Export and in the importer’s Problems section.

Stashes and sharing

Fabric lives in stashes. Everyone starts with “My Stash”; she can add more (e.g. “Quilting cottons”) from the stash button or by tapping the title. The catalog, Add Fabric, look-alike checks, Siri answers, the widget and backups all use the stash she’s in (StashSession, remembered in the App Group).

Sharing (Stashes and Sharing → ⋯ → Share…) uses the standard iCloud invite sheet: Messages, Mail or a link, with view-only or can-edit access. Everyone with edit access can add and edit fabric at the same time, which makes two people cataloging one stash practical. Tapping an invitation opens the app and switches to the stash once it syncs. People can leave a stash they were invited to; the owner manages people or stops sharing from the same sheet. In a shared stash, each fabric shows who added it.

How it’s stored (StashModel.swift, StashStore.swift):

Testing sharing needs two Apple IDs on two devices (the simulator can’t). Check: share a stash from one, accept on the other, add fabric on both, confirm it appears on each, confirm “added by”, leave, and stop sharing.

Home-screen widget

Small and medium widgets (iPhone, iPad, Mac) show the fabric count, total yards, top colors and the newest swatches; tapping one opens Add Fabric. The app writes a small StashSnapshot to the shared App Group group.com.remor.fabricstash whenever the stash changes, and the widget reads it. Setup: in Xcode, add the App Groups capability with that group to both the FabricStash and FabricWidget targets (the entitlements files already list it). The layout lives in StashWidgetContent (FabricKit) and is rendered to Tests/Fixtures/report/widget-*.png by the tests.

Exporting, backup and restore

Her data is never locked in: everything exports to ordinary files, and a backup restores fully.

Sort & filter menu → Export:

Settings → Your data has **Back Up “”…** (the stash she's in) plus **Restore from Backup…** (into the stash she's in).

Restoring: in the Files app (or Finder), tap the backup .zip once to unzip it, then choose the folder it makes, or the folder that contains it. The app never reads zip files itself; unzipping is left to Apple’s tools, so restore only reads plain files from a folder. It recognizes its own backups by a fabrics.json whose app is “Fabric Catalog”. It shows what’s inside and what it would add, then adds only the fabric she doesn’t already have in any stash. Fabric IDs survive the round trip, so restoring twice, or onto a device that already synced part of the stash, never makes duplicates. If she picks the still-zipped file, she gets the directions instead of an error. Restore also refuses image paths that point outside the backup folder, including through symlinks. Restored fabrics get their look-alike fingerprints rebuilt in the background. Capture logs aren’t part of a backup, so they’re never restored.

Development Export (real-world tuning)

While she adds fabrics, the app keeps a small capture log with each one. It records what speech recognition heard, the voice commands she used, the model’s raw answer, what the app suggested, what she saved, the new names she confirmed or rejected, retakes, look-alike decisions, the crop box and the measured colors and pattern, the selvage text, and timings. Edits she makes later in the detail screen are noted too. The log, and the full original photo (the fabric itself keeps only the square swatch she reviewed), are development data, so they stay on the device that captured the fabric: it lives in a local-only store (CaptureRecord, linked to the fabric by ID), is never saved to iCloud and is never part of a shared stash. Since it isn’t in CloudKit, its format can keep changing freely. The trade-off: logs from captures on her iPad stay on the iPad, and a lost phone loses its logs.

Gear button → Settings:

On the Mac, turn an export into test material:

scripts/import-dev-export.sh "Fabric Catalog Development Export 2026-11-09.zip"

This does three things:

Everything imported is git-ignored, so her photos and words never get committed.

Demo data (debug builds)

Launch with -seedDemoData to fill an empty catalog with 10 generated sample fabrics, which is handy for the simulator and screenshots. In Xcode: Product → Scheme → Edit Scheme → Run → Arguments. From the terminal:

xcrun simctl launch booted com.remor.fabricstash -seedDemoData

It only seeds when the store is empty, and the code isn’t compiled into release builds.

Code quality

Same setup as the Nerts project:

scripts/quality-check.sh lint          # SwiftLint (also runs on every Xcode build)
scripts/quality-check.sh format-check  # SwiftFormat (brew install swiftformat)
scripts/quality-check.sh test          # FabricKit unit tests via SwiftPM
scripts/quality-check.sh all           # everything, incl. xcodebuild analyze

Real-photo swatch tests

Drop photos of fabric being held up into FabricKit/Tests/Fixtures/holding/ (optionally describe each one in expectations.json; see the README there) and run:

scripts/photo-report.sh

It runs every photo through the real crop, color and pattern pipeline on the Mac, checks the expectations, and opens a contact sheet showing each photo with the chosen crop drawn on it.

Confirming new names

A designer, manufacturer or collection the app doesn’t already know (not in the built-in list, not already in her stash), or one she hedged about (“not sure if it’s Moda”), is never saved silently. In voice mode the app asks (“I don’t know that name yet. Is Juniper Hollow the designer?”); “yes” keeps it, “no” leaves the field blank. On screen a “New names: is this right?” row with Yes/No appears, and Save waits until it’s answered. Names she types herself count as confirmed. Once saved, a confirmed name is known from then on.

Measuring trust: PromptEval

Designer, collection, manufacturer and “where it came from” have to be trustworthy, so they’re measured against the real on-device model:

cd FabricKit && EVAL_PROMPT=1 swift test --filter PromptEval

It runs hand-written cases (what she says plus optional selvage text, with the correct answers) and reports, for the raw model and for the final result after the app’s rules, how often each field is correct and how often it is never wrong (blank is acceptable, invented is not). holdout2 holds cases the rules were never tuned on; that’s the honest number. Nov 2026, held-out: 90% correct, 96% never wrong, 100% never wrong without asking her first. Add transcripts of her real speech as new cases; that’s the test set that matters most. The rules live in FabricKit/Sources/FabricKit/AI/FieldRules.swift, and each one has a fast unit test in TrustRuleTests.swift.

ModelIntegrationTests calls the real on-device model and is skipped automatically where Apple Intelligence isn’t available.