Skip to content

v7.0.0

Latest

Choose a tag to compare

@JacobHearst JacobHearst released this 06 Oct 18:55

ScryfallKit v7.0.0

Caution

This release contains the following breaking changes:

  • Async/await only. The completion-handler APIs on ScryfallClient are removed. Use the async methods.
  • Unknown-case enums are now RawRepresentable structs. Types that previously had an .unknown(String) case are now structs with static members, so new Scryfall values decode without being lost.
  • Removed deprecated API. Card.Symbol.cmc is gone; use manaValue.

Fixes

  • Fixed a concurrency bug in RateLimiter.
  • The DocC plugin is now added dynamically, so packages that depend on ScryfallKit no longer have to resolve swift-docc-plugin.

Migrating from v6

Completion handlers → async/await

All completion-handler methods on ScryfallClient are removed. The async variants keep the same names and parameters, so drop the completion: argument and await the result.

// Before
client.getCardByName(fuzzy: "Lightning Bolt") { result in
  switch result {
  case .success(let card): ...
  case .failure(let error): ...
  }
}

// After
let card = try await client.getCardByName(fuzzy: "Lightning Bolt")

.unknown(String) → RawRepresentable structs

Affected types: Game, Card.Layout, Card.Finish, Card.Frame, Card.FrameEffect, Card.BorderColor, Card.ProducedColor, Card.SecurityStamp, Card.RelatedCard.Component, Card.Ruling.Source and MTGSet.Kind.

Static members such as .foil and .normal still work. Things to update:

  • Remove case .unknown(let raw). Read .rawValue instead.
  • Add a default to switches. Structs can't be matched exhaustively.
  • init(rawValue:) is no longer failable. It never returns nil, so Finish(rawValue: "x") ?? ... and if let no longer compile.
  • CaseIterable still works. allCases lists only the known values.
// Before
switch card.layout {
case .normal: ...
case .unknown(let raw): log(raw)
default: ...
}

// After
switch card.layout {
case .normal: ...
default: log(card.layout.rawValue)
}

Removed deprecated API

Card.Symbol.cmc and its initializer parameter are removed. Use manaValue.