Initial scaffold: context-aware notes app for iOS + macOS

XcodeGen project (Notes / NotesMac / NotesTests), Swift 6 strict concurrency,
iCloud-document storage via IndieSync with a SwiftData cache, automatic
capture context (location, place, time zone, device) on every note,
context-based relevance ranking with a 'Right here, right now' shelf,
tags, search, and the square.and.pencil-on-red app icon.
This commit is contained in:
2026-07-14 20:30:46 -04:00
commit 9b231a1978
42 changed files with 2126 additions and 0 deletions
+47
View File
@@ -0,0 +1,47 @@
import Foundation
import IndieSync
import Testing
@testable import Notes
struct NoteDocumentTests {
private func makeNote() -> Note {
var context = CaptureContext.empty
context.latitude = 37.8044
context.longitude = -122.2712
context.placeName = "Blue Bottle Coffee"
context.locality = "Oakland"
context.timeZoneID = "America/Los_Angeles"
context.device = "iPhone"
return Note.create(text: "Barista's name is Sam\nLikes cortados", tags: ["coffee", "people"], context: context)
}
@Test func codableRoundTrip() throws {
let note = makeNote()
let data = try DocumentCoder.encode(note)
let decoded = try DocumentCoder.decode(Note.self, from: data)
#expect(decoded.payload == note.payload)
#expect(decoded.meta.id == note.meta.id)
#expect(decoded.meta.schemaVersion == note.meta.schemaVersion)
// ISO-8601 encoding truncates sub-second precision.
#expect(abs(decoded.meta.createdAt.timeIntervalSince(note.meta.createdAt)) < 1)
#expect(abs(decoded.meta.modifiedAt.timeIntervalSince(note.meta.modifiedAt)) < 1)
}
@Test func forwardGateQuarantinesNewerSchema() {
var note = makeNote()
note.meta.schemaVersion = Note.currentSchemaVersion + 1
#expect(!note.isReadable)
#expect(makeNote().isReadable)
}
@Test func relativePathIsUTCBucketed() {
let note = makeNote()
let path = note.relativePath
#expect(path.hasSuffix("\(note.meta.id.stringValue).json"))
#expect(path == TimeBucketedLayout.relativePath(for: note.meta.id))
}
@Test func titleIsFirstLine() {
#expect(makeNote().title == "Barista's name is Sam")
}
}