Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ body:
required: false
- label: If possible, I've reproduced the issue using the `main` branch of this package.
required: false
- label: This issue hasn't been addressed in an [existing GitHub issue](https://github.com/pointfreeco/sharing-grdb/issues) or [discussion](https://github.com/pointfreeco/sharing-grdb/discussions).
- label: This issue hasn't been addressed in an [existing GitHub issue](https://github.com/pointfreeco/sqlite-data/issues) or [discussion](https://github.com/pointfreeco/sqlite-data/discussions).
required: true
- type: textarea
attributes:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ jobs:
env:
INCOMING_WEBHOOK_URL: ${{ secrets.SLACK_PROJECT_CHANNEL_WEBHOOK_URL }}
with:
text: sharing-grdb ${{ github.event.release.tag_name }} has been released.
text: sqlite-data ${{ github.event.release.tag_name }} has been released.
blocks: |
[
{
"type": "header",
"text": {
"type": "plain_text",
"text": "sharing-grdb ${{ github.event.release.tag_name}}"
"text": "sqlite-data ${{ github.event.release.tag_name}}"
}
},
{
Expand Down Expand Up @@ -56,14 +56,14 @@ jobs:
env:
INCOMING_WEBHOOK_URL: ${{ secrets.SLACK_RELEASES_WEBHOOK_URL }}
with:
text: sharing-grdb ${{ github.event.release.tag_name }} has been released.
text: sqlite-data ${{ github.event.release.tag_name }} has been released.
blocks: |
[
{
"type": "header",
"text": {
"type": "plain_text",
"text": "sharing-grdb ${{ github.event.release.tag_name}}"
"text": "sqlite-data ${{ github.event.release.tag_name}}"
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,56 +26,6 @@
"idiom" : "universal",
"platform" : "ios",
"size" : "1024x1024"
},
{
"idiom" : "mac",
"scale" : "1x",
"size" : "16x16"
},
{
"idiom" : "mac",
"scale" : "2x",
"size" : "16x16"
},
{
"idiom" : "mac",
"scale" : "1x",
"size" : "32x32"
},
{
"idiom" : "mac",
"scale" : "2x",
"size" : "32x32"
},
{
"idiom" : "mac",
"scale" : "1x",
"size" : "128x128"
},
{
"idiom" : "mac",
"scale" : "2x",
"size" : "128x128"
},
{
"idiom" : "mac",
"scale" : "1x",
"size" : "256x256"
},
{
"idiom" : "mac",
"scale" : "2x",
"size" : "256x256"
},
{
"idiom" : "mac",
"scale" : "1x",
"size" : "512x512"
},
{
"idiom" : "mac",
"scale" : "2x",
"size" : "512x512"
}
],
"info" : {
Expand Down
8 changes: 1 addition & 7 deletions Examples/CloudKitDemo/CloudKitDemo.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,13 @@
<dict>
<key>aps-environment</key>
<string>development</string>
<key>com.apple.developer.aps-environment</key>
<string>development</string>
<key>com.apple.developer.icloud-container-identifiers</key>
<array>
<string>iCloud.co.pointfree.SQLiteData.demos.CloudKitDemo</string>
<string>iCloud.co.pointfree.SQLiteData.CloudKitDemo</string>
</array>
<key>com.apple.developer.icloud-services</key>
<array>
<string>CloudKit</string>
</array>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.files.user-selected.read-only</key>
<true/>
</dict>
</plist>
100 changes: 41 additions & 59 deletions Examples/CloudKitDemo/CloudKitDemoApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ import CloudKit
import SQLiteData
import SwiftUI

#if canImport
import UIKit
#endif

@main
struct CloudKitDemoApp: App {
#if canImport(UIKit)
@UIApplicationDelegateAdaptor private var appDelegate: AppDelegate
#endif
@UIApplicationDelegateAdaptor private var appDelegate: AppDelegate

init() {
try! prepareDependencies {
try $0.bootstrapDatabase()
}
}

var body: some Scene {
WindowGroup {
NavigationStack {
Expand All @@ -20,62 +21,43 @@ struct CloudKitDemoApp: App {
}
}

#if canImport(UIKit)
class AppDelegate: UIResponder, UIApplicationDelegate, ObservableObject {
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication
.LaunchOptionsKey: Any]? = nil
) -> Bool {
try! prepareDependencies {
$0.defaultDatabase = try appDatabase()
$0.defaultSyncEngine = try SyncEngine(
for: $0.defaultDatabase,
tables: Counter.self
)
}
return true
}

func application(
_ application: UIApplication,
configurationForConnecting connectingSceneSession: UISceneSession,
options: UIScene.ConnectionOptions
) -> UISceneConfiguration {
let configuration = UISceneConfiguration(
name: "Default Configuration",
sessionRole: connectingSceneSession.role
)
configuration.delegateClass = SceneDelegate.self
return configuration
}
class AppDelegate: UIResponder, UIApplicationDelegate, ObservableObject {
func application(
_ application: UIApplication,
configurationForConnecting connectingSceneSession: UISceneSession,
options: UIScene.ConnectionOptions
) -> UISceneConfiguration {
let configuration = UISceneConfiguration(
name: "Default Configuration",
sessionRole: connectingSceneSession.role
)
configuration.delegateClass = SceneDelegate.self
return configuration
}
}

class SceneDelegate: UIResponder, UIWindowSceneDelegate {
@Dependency(\.defaultSyncEngine) var syncEngine
var window: UIWindow?
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
@Dependency(\.defaultSyncEngine) var syncEngine
var window: UIWindow?

func windowScene(
_ windowScene: UIWindowScene,
userDidAcceptCloudKitShareWith cloudKitShareMetadata: CKShare.Metadata
) {
Task {
try await syncEngine.acceptShare(metadata: cloudKitShareMetadata)
}
func windowScene(
_ windowScene: UIWindowScene,
userDidAcceptCloudKitShareWith cloudKitShareMetadata: CKShare.Metadata
) {
Task {
try await syncEngine.acceptShare(metadata: cloudKitShareMetadata)
}
}

func scene(
_ scene: UIScene,
willConnectTo session: UISceneSession,
options connectionOptions: UIScene.ConnectionOptions
) {
guard let cloudKitShareMetadata = connectionOptions.cloudKitShareMetadata
else {
return
}
Task {
try await syncEngine.acceptShare(metadata: cloudKitShareMetadata)
}
func scene(
_ scene: UIScene,
willConnectTo session: UISceneSession,
options connectionOptions: UIScene.ConnectionOptions
) {
guard let cloudKitShareMetadata = connectionOptions.cloudKitShareMetadata
else { return }
Task {
try await syncEngine.acceptShare(metadata: cloudKitShareMetadata)
}
}
#endif
}
74 changes: 45 additions & 29 deletions Examples/CloudKitDemo/CountersListFeature.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,7 @@ struct CountersListView: View {
.buttonStyle(.borderless)
}
.onDelete { indexSet in
withErrorReporting {
try database.write { db in
for index in indexSet {
try Counter.find(counters[index].id).delete()
.execute(db)
}
}
}
deleteRows(at: indexSet)
}
}
}
Expand All @@ -42,6 +35,17 @@ struct CountersListView: View {
}
}
}

func deleteRows(at indexSet: IndexSet) {
withErrorReporting {
try database.write { db in
for index in indexSet {
try Counter.find(counters[index].id).delete()
.execute(db)
}
}
}
}
}

struct CounterRow: View {
Expand All @@ -55,32 +59,14 @@ struct CounterRow: View {
HStack {
Text("\(counter.count)")
Button("-") {
withErrorReporting {
try database.write { db in
try Counter.find(counter.id).update {
$0.count -= 1
}
.execute(db)
}
}
decrementButtonTapped()
}
Button("+") {
withErrorReporting {
try database.write { db in
try Counter.find(counter.id).update {
$0.count += 1
}
.execute(db)
}
}
incrementButtonTapped()
}
Spacer()
Button {
Task {
sharedRecord = try await syncEngine.share(record: counter) { share in
share[CKShare.SystemFieldKey.title] = "Join my counter!"
}
}
shareButtonTapped()
} label: {
Image(systemName: "square.and.arrow.up")
}
Expand All @@ -90,4 +76,34 @@ struct CounterRow: View {
CloudSharingView(sharedRecord: sharedRecord)
}
}

func shareButtonTapped() {
Task {
sharedRecord = try await syncEngine.share(record: counter) { share in
share[CKShare.SystemFieldKey.title] = "Join my counter!"
}
}
}

func decrementButtonTapped() {
withErrorReporting {
try database.write { db in
try Counter.find(counter.id).update {
$0.count -= 1
}
.execute(db)
}
}
}

func incrementButtonTapped() {
withErrorReporting {
try database.write { db in
try Counter.find(counter.id).update {
$0.count += 1
}
.execute(db)
}
}
}
}
9 changes: 0 additions & 9 deletions Examples/CloudKitDemo/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,6 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CKSharingSupported</key>
<true/>
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
<false/>
<key>UISceneConfigurations</key>
<dict/>
</dict>
<key>UIBackgroundModes</key>
<array>
<string>remote-notification</string>
Expand Down
Loading