Skip to content

Commit

Permalink
Update macOS versions for some methods
Browse files Browse the repository at this point in the history
  • Loading branch information
rudrankriyam committed Aug 2, 2023
1 parent 8946478 commit bc6499c
Show file tree
Hide file tree
Showing 1,576 changed files with 1,745 additions and 1,655 deletions.
23 changes: 23 additions & 0 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"pins" : [
{
"identity" : "swift-docc-plugin",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-docc-plugin",
"state" : {
"revision" : "9b1258905c21fc1b97bf03d1b4ca12c4ec4e5fda",
"version" : "1.2.0"
}
},
{
"identity" : "swift-docc-symbolkit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-docc-symbolkit",
"state" : {
"revision" : "b45d1f2ed151d057b54504d653e0da5552844e34",
"version" : "1.0.0"
}
}
],
"version" : 2
}
60 changes: 27 additions & 33 deletions Sources/MusadoraKit/Library/LibraryArtist.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import MediaPlayer

public extension MLibrary {

#if compiler(>=5.7)
/// Fetch an artist from the user's library by using its identifier.
///
/// do {
Expand All @@ -27,28 +26,26 @@ public extension MLibrary {
/// and is faster because it uses the latest `MusicLibraryRequest` structure.
/// For iOS 15 devices, it uses the custom structure `MusicLibraryResourceRequest`
/// that fetches the data from Apple Music API.
@available(iOS 16.0, tvOS 16.0, watchOS 9.0, macOS 14.0, macCatalyst 17.0, *)
static func artist(id: MusicItemID) async throws -> Artist {
var request = MusicLibraryRequest<Artist>()
request.filter(matching: \.id, equalTo: id)
let response = try await request.response()

guard let artist = response.items.first else {
throw MusadoraKitError.notFound(for: id.rawValue)
}
return artist
}
#else
static func artist(id: MusicItemID) async throws -> Artist {
let request = MLibraryResourceRequest<Artist>(matching: \.id, equalTo: id)
let response = try await request.response()

guard let artist = response.items.first else {
throw MusadoraKitError.notFound(for: id.rawValue)
if #available(iOS 16.0, tvOS 16.0, watchOS 9.0, macOS 14, macCatalyst 17.0, *) {
var request = MusicLibraryRequest<Artist>()
request.filter(matching: \.id, equalTo: id)
let response = try await request.response()

guard let artist = response.items.first else {
throw MusadoraKitError.notFound(for: id.rawValue)
}
return artist
} else {
let request = MLibraryResourceRequest<Artist>(matching: \.id, equalTo: id)
let response = try await request.response()

guard let artist = response.items.first else {
throw MusadoraKitError.notFound(for: id.rawValue)
}
return artist
}
return artist
}
#endif

/// Fetch all artists from the user's library in alphabetical order.
///
Expand Down Expand Up @@ -78,7 +75,6 @@ public extension MLibrary {
}


#if compiler(>=5.7)
/// Fetch multiple artists from the user's library by using their identifiers.
///
/// do {
Expand All @@ -101,20 +97,18 @@ public extension MLibrary {
/// and is faster because it uses the latest `MusicLibraryRequest` structure.
/// For iOS 15 devices, it uses the custom structure `MusicLibraryResourceRequest`
/// that fetches the data from Apple Music API.
@available(iOS 16.0, tvOS 16.0, watchOS 9.0, macOS 14.0, macCatalyst 17.0, *)
static func artists(ids: [MusicItemID]) async throws -> Artists {
var request = MusicLibraryRequest<Artist>()
request.filter(matching: \.id, memberOf: ids)
let response = try await request.response()
return response.items
}
#else
static func artists(ids: [MusicItemID]) async throws -> Artists {
let request = MLibraryResourceRequest<Artist>(matching: \.id, memberOf: ids)
let response = try await request.response()
return response.items
if #available(iOS 16.0, tvOS 16.0, watchOS 9.0, macOS 14, macCatalyst 17.0, *) {
var request = MusicLibraryRequest<Artist>()
request.filter(matching: \.id, memberOf: ids)
let response = try await request.response()
return response.items
} else {
let request = MLibraryResourceRequest<Artist>(matching: \.id, memberOf: ids)
let response = try await request.response()
return response.items
}
}
#endif

#if compiler(>=5.7)
/// Accesses the total number of artists in the user's music library.
Expand Down
14 changes: 10 additions & 4 deletions Sources/MusadoraKit/Library/LibrarySong.swift
Original file line number Diff line number Diff line change
Expand Up @@ -413,11 +413,17 @@ public extension MLibrary {
///
/// - Note: This method fetches the songs locally from the device,
/// and is faster because it uses the latest `MusicLibraryRequest` structure.
@available(iOS 16.0, macOS 14.0, macCatalyst 17.0, tvOS 16.0, watchOS 9.0, *)
@available(iOS 16.0, tvOS 16.0, watchOS 9.0, *)
@available(macOS, unavailable)
@available(macCatalyst, unavailable)
static func songsForGenres() async throws -> SongsForGenres {
let request = MusicLibrarySectionedRequest<Genre, Song>()
let response = try await request.response()
return response.sections
if #available(macOS 14.0, *) {
let request = MusicLibrarySectionedRequest<Genre, Song>()
let response = try await request.response()
return response.sections
} else {
return []
}
}

/// Fetch all songs from the user's library for all artists.
Expand Down
4 changes: 3 additions & 1 deletion Sources/MusadoraKit/Models/SongsForGenres.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@
/// A type alias representing a collection of songs for multiple genres.
///
/// This alias is used to manage and manipulate a collection of `SongsForGenre` items.
@available(iOS 16.0, macOS 14.0, macCatalyst 17.0, tvOS 16.0, watchOS 9.0, *)
@available(iOS 16.0, tvOS 16.0, watchOS 9.0, *)
@available(macOS, unavailable)
@available(macCatalyst, unavailable)
public typealias SongsForGenres = [MusicLibrarySection<Genre, Song>]
9 changes: 0 additions & 9 deletions docs/css/chunk-384ef189.7ede1ea3.css

This file was deleted.

9 changes: 9 additions & 0 deletions docs/css/chunk-c0335d80.10a2f091.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions docs/css/documentation-topic.1d1eec04.css

Large diffs are not rendered by default.

9 changes: 0 additions & 9 deletions docs/css/documentation-topic.29351f99.css

This file was deleted.

9 changes: 9 additions & 0 deletions docs/css/documentation-topic~topic.b6287bcf.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit bc6499c

Please sign in to comment.