r/iOSProgramming • • 7d ago

App Saturday App Saturday: Near, a countdown app built on SwiftData, CloudKit sharing, WidgetKit and on-device Foundation Models

Hi all. I'm the solo developer of Near, a countdown and count-up app for iPhone with photo widgets and shared countdowns.

Tech Stack

  • Swift 6 with strict concurrency, SwiftUI, iOS 26
  • SwiftData for storage, CloudKit sharing for countdowns shared between family members
  • WidgetKit (Home Screen and Lock Screen widgets) and ActivityKit (a Live Activity on the day itself)
  • Foundation Models (Apple's on-device model) for natural-language entry, with a heuristic parser as fallback
  • StoreKit 2 for the Near+ purchase, App Intents
  • XcodeGen for the project file

Development Challenge
Photo widgets kept rendering blank with no error. Widget extensions have a tight memory budget, and full-size photos from the library blow straight past it. The fix: downsample with ImageIO (CGImageSourceCreateThumbnailAtIndex, max 800 px, without decoding the full image) before the photo goes into the timeline entry, then re-encode as JPEG. The widgets have been reliable since.

A second one: natural-language entry ("Mom lands Dec 22 at 6pm") uses the on-device model, but it isn't available on every device or language, so a rule-based parser handles the same input when the model can't.

AI Disclosure
AI-assisted. I built it with Claude Code as a pair programmer: it wrote a lot of the SwiftUI and boilerplate under rules I set in the repo, and I designed the app, made the architecture decisions, and debugged and tested everything on device.

Free with up to three upcoming moments; Near+ is an optional in-app purchase. Happy to answer anything about the code.

https://apps.apple.com/app/id6772564252

4 Upvotes

7 comments sorted by

1

u/Kind-Survey925 7d ago

Where does it persist the countdowns? Installing the app on a new phone would load/sync them?

1

u/JOSHGREENONLINE 5d ago

SwiftData synced through your own private iCloud. Install it on a new phone signed into the same Apple Account and your countdowns sync down. There's no server on my end, so I never see any of it.

If you're not signed into iCloud they stay on that one phone, so there's also a backup export in Settings > Import & Export.

1

u/Kind-Survey925 5d ago

cool! thanks

1

u/laplace_apps 6d ago

The ImageIO downsampling fix is worth writing down for others. Blank widgets with no error is a really confusing failure, and it's almost always the extension memory limit. Curious how you did the family sharing: last I looked SwiftData didn't support CloudKit shared databases out of the box. Did you keep a Core Data / NSPersistentCloudKitContainer store just for the shared countdowns, or work with CKShare directly?

1

u/JOSHGREENONLINE 5d ago

Went straight to CKShare. SwiftData's CloudKit mirror only reaches the private database, so shared countdowns are synced by hand:

  • Each shared moment gets its own record zone in the owner's private DB (`NearMoment-<uuid>`) holding one `SharedMoment` record
  • The zone gets a zone-wide `CKShare`. Invites go through `UICloudSharingController`, participants get read-write, and public permission is `.none` so a forwarded link opens nothing
  • Owner reads and writes in the private DB, participants in the shared DB
  • Each device keeps a small `SharedMomentLink` model next to the local `Moment` with the last server modification date it applied, so a pull only touches the moment when the record actually changed
  • Pull on launch and every time the app comes to the foreground, push on edit. No subscriptions yet; foreground sync is plenty for a countdown

First version used record-level shares in a single zone. Moved to one zone per moment.

And yeah, agreed on the widgets. Covers get downsampled with `CGImageSourceCreateThumbnailAtIndex` to 800px max, no full decode, before they go into the timeline entry. Blank widget with no error was a fun one to track down.

1

u/[deleted] 4d ago

[removed] — view removed comment

1

u/AutoModerator 4d ago

Hey /u/protovv, your content has been removed because Reddit has marked your account as having a low Contributor Quality Score. This may result from, but is not limited to, activities such as spamming the same links across multiple subreddits, submitting posts or comments that receive a high number of downvotes, a lack of recent account activity, or having an unverified account.

Please be assured that this action is not a reflection of your participation in our subreddit. This is simply an automated filter in place to reduce spam.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.