About this project
# Swift UUIDV7
An RFC 9562 compliant UUID v7 data type for Swift, providing cross-platform support and integrations with popular libraries. Unlike Foundation's `UUID` (typically v4), `UUIDV7` embeds a timestamp in its most significant 48 bits, enabling ordinality and better index locality for database primary keys.
## Key Features
- **Timestamp-based ordering**: Sort collections by `UUIDV7` as a sort key.
- **Sub-millisecond monotonicity**: Guarantees monotonically increasing generations 100% of the time, even if the system clock changes backwards.
- **RawRepresentable**: Uses a Foundation `UUID` as its raw value, with dynamic member lookup for all typical `UUID` properties.
- **Library integrations** via package traits:
- `SwiftUUIDV7Tagged`: Convenience initializers for `Tagged`.
- `SwiftUUIDV7GRDB`: `DatabaseValueConvertible` and `StatementColumnConvertible` conformances, plus database functions.
- `SwiftUUIDV7StructuredQueries`: `QueryBindable` conformance and column representations.
- `SwiftUUIDV7Dependencies`: A `UUIDV7Generator` dependency.
- `SwiftUUIDV7SQLiteData`: CloudKit sync compatibility via `IdentifierStringConvertible`.
- **AppIntents**: Conforms to `EntityIdentifierConvertible` on Apple platforms.
## Installation
Add as a Swift Package Manager dependency:
```swift
dependencies: [
.package(
url: "https://github.com/mhayes853/swift-uuidv7",
from: "0.6.1",
traits: ["SwiftUUIDV7GRDB"]
)
]
```
Or copy `Sources/UUIDV7/UUIDV7.swift` directly into your project.
## License
MIT License.
Comments
0 people shared their preference · Deer Point appears after 10 participants
Sign in to join the discussion.