Point-Free
banner
pointfree.co
Point-Free
@pointfree.co
1.2K followers 220 following 410 posts
A video series exploring advanced topics in the Swift programming language, hosted by @mbrandonw.bsky.social and @stephencelis.com.
Posts Media Videos Starter Packs
Pinned
This week we gave a brief overview of the concept of "callbacks" in databases, which Rails popularized and many other frameworks adopted.

They allow you to execute little bits of logic when a row is inserted/updated/deleted in your database.

Learn more here:
www.pointfree.co/episodes/ep3...
Episode #330: Persistence Callbacks: Triggers
We continue our series on “modern persistence” with an important topic: “callbacks.” Callbacks are little hooks into the lifecycle of your data model so that you can be notified or take action when so...
www.pointfree.co
One of the most difficult parts of distributing your user's data across multiple devices is handling when devices have different versions of the schema.

Our SQLiteData library handles this seamlessly behind the scenes without you having to think about it.

Quick demo here 👇
SQLiteData now lets you define your own custom aggregate functions in Swift. Simply add the @‌DatabaseFunction macro to a function that operates on a sequence of values: www.pointfree.co/blog/posts/1...
New in SQLiteData: Custom aggregate functions
We have added the ability to use Swift functions to aggregate data in your SQLite queries using a syntax that is unobtrusive
www.pointfree.co
Reposted by Point-Free
It is positively addicting to watch data flowing from a device in a test vehicle to a device on my desk in real-time. Outstanding job on this implementation. I wish I had a job because I would surely be in line for a huge raise for adding this amazing feature.
Reposted by Point-Free
Watched this new episode and had CloudKit synchronization up and running in about 10 minutes. I previously had converted all my integer IDs to UUIDs so other than removing a unique constraint, it compiled and started syncing right away.
How are conflicts handled in our SQLite+iCloud synchronization tools?

We use a “last edit wins” strategy on a per-field basis. This means if you edit the title of a reminder on one device and the notes on another, it will all merge cleanly.
Adding iCloud synchronization to your app can introduce hidden complexity. It may seem like your app isn't sending data to or receiving data from iCloud.

That's why our SyncEngine logs detailed messages, so you know exactly what is happening under the hood.
This tip is just one of many from this week’s video.

Watch today: www.pointfree.co/episodes/ep3...
Did you know you can bind a SwiftUI text field to a URL?

The simplest way is with a custom computed get/set property, which allows you to derive a binding via dynamic member lookup:
Would you believe that adding iCloud sync to an app can be as simple as adding a single line of code?

It’s true! The following video shows how: www.pointfree.co/episodes/ep3...
The “SyncEngine” seamlessly synchronizes data to and from iCloud, resolves conflicts when records are edited and deleted concurrently from many devices, and can even synchronized records across different app and schema versions.

Watch how: www.pointfree.co/episodes/ep3...
SQLiteData 1.1 introduces powerful new domain modeling tools that put you in control of the structure of your model types. Instead of describing your table as a flat struct with a property per column, you can nest groups of columns into structs (and even enums!) of their own.
Have you wanted to know what it takes to build an app using modern persistence techniques? This means using structs and enums instead of classes, bringing SQLite to the forefront instead of abstracting it away, and multi-device synchronization that just works.

Well… pointfree.co/pricing
We are finally putting the “modern” in our “Modern Persistence” series by showing what it takes to start synchronizing your user’s data to all of their devices.

Follow along here: www.pointfree.co/collections/...
We are finally putting the “modern” in our “Modern Persistence” series by showing what it takes to start synchronizing your user’s data to all of their devices.

Follow along here: www.pointfree.co/collections/...
SQLiteData offers seamless iCloud sync, but only if your schema is designed with synchronization in mind. If not, you could have 100s of lines of migration code ahead of you.

Luckily version 1.1 brings a brand new tool to automate this work in a single statement:
To synchronize a SQLite database to CloudKit each table must have a globally unique primary key (e.g. auto-incrementing ints do not work).

It can be quite the slog to migrate a database to meet these requirements, but on Point-Free we don't shy away from this kind of real world messiness!
There's a little bit of extra secret sauce in that code snippet above. We also have a type-safe and schema-safe access to SQLite's pragmas, such as getting the foreign keys for a table:

github.com/pointfreeco/...

Check out all of the pragmas here:

github.com/pointfreeco/...
We accomplish this by topologically sorting the tables in your schema based on the foreign key relationships. This allows us to detect when a child record is sync'd to the device before its parent so that we can delay it until the parent is received.

Here's the sauce: github.com/pointfreeco/...
sqlite-data/Sources/SQLiteData/CloudKit/SyncEngine.swift at 320a0023a168c2efd37dcd3933a8359c35d092cf · pointfreeco/sqlite-data
A fast, lightweight replacement for SwiftData, powered by SQL and supporting CloudKit synchronization. - pointfreeco/sqlite-data
github.com
We went above and beyond with our SQLite+CloudKit sync tools by supporting foreign key constraints. This allows you to embrace data integrity in an integrity hostile environment (i.e. distributed schema).
Reposted by Point-Free
How easy is it to add iCloud sync to an app? A single line? Hundreds? Depends on how your database schema is designed! We get our hands dirty and show that even in the messiest of situations there is a clear path forward, and we can even make it quite nice. www.pointfree.co/episodes/ep3...