Skip to content

Commit 97eb047

Browse files
committed
Merge branch 'main' into cloudkit
2 parents 20e9cd6 + 5b23ef4 commit 97eb047

File tree

6 files changed

+44
-35
lines changed

6 files changed

+44
-35
lines changed

Examples/Examples.xcodeproj/project.pbxproj

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
CA1146AC2DF38D000054BA77 /* CloudKitDemoTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CloudKitDemoTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
6363
CA5F37542D5AFBBC002E1A9E /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
6464
CA9101C82E1F270100F85DD0 /* CloudKitPlayground.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CloudKitPlayground.app; sourceTree = BUILT_PRODUCTS_DIR; };
65-
CA9102E62E1F28FE00F85DD0 /* sharing-grdb-icloud */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = "sharing-grdb-icloud"; path = "/Users/brandon/projects/sharing-grdb-icloud"; sourceTree = "<absolute>"; };
65+
CA9102E62E1F28FE00F85DD0 /* sharing-grdb */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = "sharing-grdb"; path = "/Users/brandon/projects/sharing-grdb"; sourceTree = "<absolute>"; };
6666
CA9F99482DF9134D00934431 /* RemindersTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RemindersTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
6767
CAD0017D2D874E6F00FA977A /* SyncUpTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SyncUpTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
6868
CAF836982D4735620047AEB5 /* CaseStudies.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CaseStudies.app; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -295,7 +295,7 @@
295295
CAF837022D4735C00047AEB5 /* Frameworks */ = {
296296
isa = PBXGroup;
297297
children = (
298-
CA9102E62E1F28FE00F85DD0 /* sharing-grdb-icloud */,
298+
CA9102E62E1F28FE00F85DD0 /* sharing-grdb */,
299299
);
300300
name = Frameworks;
301301
sourceTree = "<group>";
@@ -578,7 +578,7 @@
578578
DCBE8A122D4842BF0071F499 /* XCRemoteSwiftPackageReference "swift-case-paths" */,
579579
DCF267372D48437300B680BE /* XCRemoteSwiftPackageReference "swift-navigation" */,
580580
DC5FA7462D4C63D60082743E /* XCRemoteSwiftPackageReference "swift-dependencies" */,
581-
CA9102E92E1F299900F85DD0 /* XCLocalSwiftPackageReference "../../sharing-grdb-icloud" */,
581+
CA9102E92E1F299900F85DD0 /* XCLocalSwiftPackageReference ".." */,
582582
);
583583
preferredProjectObjectVersion = 77;
584584
productRefGroup = CAF836992D4735620047AEB5 /* Products */;
@@ -1433,9 +1433,9 @@
14331433
/* End XCConfigurationList section */
14341434

14351435
/* Begin XCLocalSwiftPackageReference section */
1436-
CA9102E92E1F299900F85DD0 /* XCLocalSwiftPackageReference "../../sharing-grdb-icloud" */ = {
1436+
CA9102E92E1F299900F85DD0 /* XCLocalSwiftPackageReference ".." */ = {
14371437
isa = XCLocalSwiftPackageReference;
1438-
relativePath = "../../sharing-grdb-icloud";
1438+
relativePath = "..";
14391439
};
14401440
/* End XCLocalSwiftPackageReference section */
14411441

@@ -1500,17 +1500,17 @@
15001500
};
15011501
CA9102EC2E1F29A400F85DD0 /* SharingGRDB */ = {
15021502
isa = XCSwiftPackageProductDependency;
1503-
package = CA9102E92E1F299900F85DD0 /* XCLocalSwiftPackageReference "../../sharing-grdb-icloud" */;
1503+
package = CA9102E92E1F299900F85DD0 /* XCLocalSwiftPackageReference ".." */;
15041504
productName = SharingGRDB;
15051505
};
15061506
CA9102EE2E1F29AA00F85DD0 /* SharingGRDB */ = {
15071507
isa = XCSwiftPackageProductDependency;
1508-
package = CA9102E92E1F299900F85DD0 /* XCLocalSwiftPackageReference "../../sharing-grdb-icloud" */;
1508+
package = CA9102E92E1F299900F85DD0 /* XCLocalSwiftPackageReference ".." */;
15091509
productName = SharingGRDB;
15101510
};
15111511
CA9102F02E1F29E300F85DD0 /* SharingGRDB */ = {
15121512
isa = XCSwiftPackageProductDependency;
1513-
package = CA9102E92E1F299900F85DD0 /* XCLocalSwiftPackageReference "../../sharing-grdb-icloud" */;
1513+
package = CA9102E92E1F299900F85DD0 /* XCLocalSwiftPackageReference ".." */;
15141514
productName = SharingGRDB;
15151515
};
15161516
CA9F99D72DF915D300934431 /* DependenciesTestSupport */ = {

Examples/Examples.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Examples/Reminders/Helpers.swift

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,11 @@ extension Color {
55
public struct HexRepresentation: QueryBindable, QueryRepresentable {
66
public var queryOutput: Color
77
public var queryBinding: QueryBinding {
8-
guard let components = UIColor(queryOutput).cgColor.components
9-
else {
8+
guard let hexValue else {
109
struct InvalidColor: Error {}
1110
return .invalid(InvalidColor())
1211
}
13-
let r = Int64(components[0] * 0xFF) << 24
14-
let g = Int64(components[1] * 0xFF) << 16
15-
let b = Int64(components[2] * 0xFF) << 8
16-
let a = Int64((components.indices.contains(3) ? components[3] : 1) * 0xFF)
17-
return .int(r | g | b | a)
12+
return .int(hexValue)
1813
}
1914
public init(queryOutput: Color) {
2015
self.queryOutput = queryOutput
@@ -30,5 +25,14 @@ extension Color {
3025
)
3126
)
3227
}
28+
public var hexValue: Int64? {
29+
guard let components = UIColor(queryOutput).cgColor.components
30+
else { return nil }
31+
let r = Int64(components[0] * 0xFF) << 24
32+
let g = Int64(components[1] * 0xFF) << 16
33+
let b = Int64(components[2] * 0xFF) << 8
34+
let a = Int64((components.indices.contains(3) ? components[3] : 1) * 0xFF)
35+
return r | g | b | a
36+
}
3337
}
3438
}

Examples/Reminders/Schema.swift

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@ import SwiftUI
99
struct RemindersList: Hashable, Identifiable {
1010
let id: UUID
1111
@Column(as: Color.HexRepresentation.self)
12-
var color: Color = .blue
12+
var color: Color = Self.defaultColor
1313
var position = 0
1414
var title = ""
15+
16+
static var defaultColor: Color { Color(red: 0x4a / 255, green: 0x99 / 255, blue: 0xef / 255) }
17+
static var defaultTitle: String { "Personal" }
1518
}
1619

1720
extension RemindersList.Draft: Identifiable {}
@@ -137,11 +140,12 @@ func appDatabase() throws -> any DatabaseWriter {
137140
migrator.eraseDatabaseOnSchemaChange = true
138141
#endif
139142
migrator.registerMigration("Create initial tables") { db in
143+
let defaultListColor = Color.HexRepresentation(queryOutput: RemindersList.defaultColor).hexValue
140144
try #sql(
141145
"""
142146
CREATE TABLE "remindersLists" (
143147
"id" TEXT PRIMARY KEY NOT NULL ON CONFLICT REPLACE DEFAULT (uuid()),
144-
"color" INTEGER NOT NULL ON CONFLICT REPLACE DEFAULT \(raw: 0x4a99_ef00),
148+
"color" INTEGER NOT NULL ON CONFLICT REPLACE DEFAULT \(raw: defaultListColor ?? 0),
145149
"position" INTEGER NOT NULL ON CONFLICT REPLACE DEFAULT 0,
146150
"title" TEXT NOT NULL ON CONFLICT REPLACE DEFAULT ''
147151
) STRICT
@@ -209,30 +213,26 @@ func appDatabase() throws -> any DatabaseWriter {
209213

210214
try RemindersList.createTemporaryTrigger(after: .insert { new in
211215
RemindersList
216+
.find(new.id)
212217
.update { $0.position = RemindersList.select { ($0.position.max() ?? -1) + 1} }
213-
.where { $0.id.eq(new.id) }
214-
} when: { _ in
215-
!SyncEngine.isSynchronizingChanges()
216218
})
217219
.execute(db)
218220
try Reminder.createTemporaryTrigger(after: .insert { new in
219221
Reminder
222+
.find(new.id)
220223
.update { $0.position = Reminder.select { ($0.position.max() ?? -1) + 1} }
221-
.where { $0.id.eq(new.id) }
222-
} when: { _ in
223-
!SyncEngine.isSynchronizingChanges()
224224
})
225225
.execute(db)
226-
try RemindersList.createTemporaryTrigger(
227-
after: .delete { _ in
228-
RemindersList.insert {
229-
RemindersList.Draft(color: .blue, title: "Personal")
230-
}
231-
} when: { _ in
232-
RemindersList.count().eq(0)
233-
&& !SyncEngine.isSynchronizingChanges()
226+
try RemindersList.createTemporaryTrigger(after: .delete { _ in
227+
RemindersList.insert {
228+
RemindersList.Draft(
229+
color: RemindersList.defaultColor,
230+
title: RemindersList.defaultTitle
231+
)
234232
}
235-
)
233+
} when: { _ in
234+
!RemindersList.exists()
235+
})
236236
.execute(db)
237237
}
238238

Examples/RemindersTests/SearchRemindersTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ extension BaseTestSuite {
2626
model.searchText = "Take"
2727
try await model.$reminders.load()
2828
try await model.$completedCount.load()
29-
try await Task.sleep(for: .seconds(0.1))
29+
try await Task.sleep(for: .seconds(0.5))
3030
#expect(model.completedCount == 1)
3131
assertInlineSnapshot(of: model.reminders, as: .customDump) {
3232
"""

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1+
> [!IMPORTANT]
2+
> We are currently running a [public beta] to preview our upcoming CloudKit synchronization tools. Get all the details [here](https://www.pointfree.co/blog/posts/181-a-swiftdata-alternative-with-sqlite-cloudkit-public-beta) and let us know if you have any feedback!
3+
4+
[public beta]: https://github.com/pointfreeco/sharing-grdb/pull/112
5+
16
# SharingGRDB
27

38
A [fast](#Performance), lightweight replacement for SwiftData, powered by SQL and supporting
49
CloudKit synchronization.
510

6-
[![CI](https://github.com/pointfreeco/sharing-grdb/workflows/CI/badge.svg)](https://github.com/pointfreeco/sharing-grdb/actions?query=workflow%3ACI)
11+
[![CI](https://github.com/pointfreeco/sharing-grdb/actions/workflows/ci.yml/badge.svg)](https://github.com/pointfreeco/sharing-grdb/actions/workflows/ci.yml)
712
[![Slack](https://img.shields.io/badge/slack-chat-informational.svg?label=Slack&logo=slack)](https://www.pointfree.co/slack-invite)
813
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fpointfreeco%2Fsharing-grdb%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/pointfreeco/sharing-grdb)
914
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fpointfreeco%2Fsharing-grdb%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/pointfreeco/sharing-grdb)

0 commit comments

Comments
 (0)