A Swift package that provides a convenient and type-safe wrapper around the iTunes Search API, allowing you to fetch information about applications and developers from the App Store. The package is built with modern Swift features including async/await and actors for thread-safe operations.
- 📱 Fetch app details using App Store ID
- 📦 Fetch app details using bundle identifier
- 🔍 Get other apps by the same developer from a bundle identifier
- 🌍 Full localization support
- 🔒 Thread-safe operations using Swift actors
- 👨💻 List all applications from a developer
- ℹ️ Get detailed developer information
- 🔄 Automatic error handling and type-safe responses
- iOS 16.0+ / macOS 13.0+ / tvOS 16.0+ / watchOS 9.0+
- Swift 6.0+
- Xcode 15.0+
Add the following dependency to your Package.swift
file:
dependencies: [
.package(url: "/~https://github.com/nicolasvergoz/DearApps.git", from: "1.1.1")
]
Or in Xcode:
- File > Add Packages...
- Enter package URL:
/~https://github.com/nicolasvergoz/DearApps.git
- Select version requirements
- Click "Add Package"
// Basic initialization
let api = DearAppsAPI()
// Custom initialization with specific locale and URLSession
let customSession = URLSession(configuration: .ephemeral)
let api = DearAppsAPI(
urlSession: customSession,
locale: Locale(identifier: "fr_FR")
)
// Using App Store ID
let app = try await api.getApp(appStoreId: 1533526463)
print(app.trackName) // Prints the app name
print(app.version) // Prints the app version
// Using bundle identifier
let app = try await api.getApp(bundleId: "com.example.app")
// Get other apps from the same developer (excluding current app)
let otherApps = try await api.getOtherApps(
bundleId: "com.example.app",
excludeCurrentId: true
)
// Get developer information
let developer = try await api.getDeveloper(developerId: 1533526465)
print(developer.artistName) // Prints developer name
// Fetch all apps from a developer
let apps = try await api.getApps(developerId: 1533526465)
The package provides comprehensive error handling through the DearAppsError
enum:
do {
let app = try await api.getApp(bundleId: "com.example.app")
} catch DearAppsError.appNotFound {
print("App not found")
} catch DearAppsError.noResults {
print("No results found")
} catch DearAppsError.httpError(let statusCode) {
print("HTTP error: \(statusCode)")
} catch {
print("Other error: \(error)")
}
When using DearApps with Vapor, extend the DTO models to conform to Vapor's protocols:
import DearApps
import Vapor
extension ApplicationDTO: @retroactive AsyncResponseEncodable {}
extension ApplicationDTO: @retroactive AsyncRequestDecodable {}
extension ApplicationDTO: @retroactive ResponseEncodable {}
extension ApplicationDTO: @retroactive RequestDecodable {}
extension ApplicationDTO: @retroactive Content {}
extension DeveloperDTO: @retroactive AsyncResponseEncodable {}
extension DeveloperDTO: @retroactive AsyncRequestDecodable {}
extension DeveloperDTO: @retroactive ResponseEncodable {}
extension DeveloperDTO: @retroactive RequestDecodable {}
extension DeveloperDTO: @retroactive Content {}
- Localization: Always consider using the appropriate locale for your users:
let frenchApp = try await api.getApp(
bundleId: "com.example.app",
locale: Locale(identifier: "fr_FR")
)
- Error Handling: Always handle potential errors appropriately in production code
- URLSession: Consider using a custom URLSession for better control over network behavior
- Rate Limiting: Be mindful of App Store API rate limits in production environments
Contributions are welcome! Please feel free to submit a Pull Request.
This project is available under the MIT license. See the LICENSE file for more info.
If you encounter any issues or have questions, please create an issue on GitHub.