Files
swift-musicbrainz/GEMINI.md
2026-03-21 18:25:21 +01:00

1.2 KiB

MusicBrainz Swift

Documentation and reference for the MusicBrainz API implementation.

Search API Reference

SwiftUI and SwiftData Readiness

The library is designed to be cross-platform and modern-Swift ready.

SwiftUI

All models conform to Identifiable, Hashable, and Equatable. This makes them perfect for:

  • Efficient list rendering using ForEach.
  • State management with @State or @Observable.
  • Value-based equality checks.

SwiftData Bridging

Since this library is cross-platform, it does not import SwiftData directly. To persist MusicBrainz entities in SwiftData, you should create separate @Model classes and bridge them.

Example:

import SwiftData
import MusicBrainz

@Model
class PersistentArtist {
    @Attribute(.unique) var id: String
    var name: String
    var country: String?
    
    init(from artist: MusicBrainz.Artist) {
        self.id = artist.id
        self.name = artist.name
        self.country = artist.country
    }
}

Bridging DTOs to local storage models ensures that your persistence layer remains decoupled from the network layer, which is a best practice.