A Swift library for interacting with the PokeAPI, providing easy access to Pokémon data. This library is built using Swift Concurrency and requires iOS 15+ and macOS 12+.
Add SwiftPokeKit as a dependency in your Package.swift
file:
dependencies: [
.package(url: "https://github.com/yourusername/SwiftPokeKit.git", .upToNextMajor(from: "1.0.0"))
]
Don't forget to add SwiftPokeKit to your target dependencies:
.target(name: "YourApp", dependencies: ["SwiftPokeKit"]),
First, import SwiftPokeKit in the file where you want to use it:
import SwiftPokeKit
Initialize a PokeAPIClient instance:
let pokeAPIClient = PokeAPIClient()
To fetch a Pokémon by name, call the fetchPokemon(name:) function:
async {
do {
let pokemon = try await pokeAPIClient.fetchPokemon(name: "pikachu")
print("Fetched Pokémon: \(pokemon.name)")
} catch {
print("Error fetching Pokémon: \(error)")
}
}
We welcome contributions! Feel free to submit pull requests, report issues, or suggest new features.
SwiftPokeKit is available under the MIT license. See the LICENSE file for more details.