GUID V4 - Random-Based Identifier (Recommended)
GUID v4 is the most widely used random-based identifier. Learn about its structure, collision probability, advantages and why it is recommended for general-purpose applications.
Generate UUIDs in Swift with Foundation's UUID() for native random v4 values. If your app needs UUID v7, use a third-party RFC 9562-compatible package because the standard Foundation API does not expose it directly.
let id = UUID()
print(id.uuidString)Swift Foundation does not provide native UUID v7 generation. Use a third-party package that explicitly documents RFC 9562 UUID v7 support if you need sortable UUID values.
// Foundation does not expose native UUID v7 generation.
// Use a third-party RFC 9562-compatible package when UUID v7 is required.UUID type.UUID() creates RFC 4122 version 4 random bytes.UUID(), which is the standard native API for random UUID generation in Swift.UUID() creates RFC 4122 version 4 random bytes.These articles expand on related concepts, formats and practical considerations.