A simple and scalable iOS application to browse movie details using The Movie Database (TMDB) API. This project follows a clean architecture approach with a generic network layer using URLSession.
- Fetch and display movie details
- Scalable API integration using URLSession abstractions
- Clean Architecture + MVVM and modular project structure
- Pagination support for movie lists
- Centralized API handling and Dependency Injection
- Optimized network calls with error handling
ios-swiftui-api-integration-boilerplate/
│
├── App/ # App Entry Point & Lifecycle
├── Core/ # Network layer abstractions, Constants, and Utilities
├── DI/ # Dependency Injection Container (API keys configuration)
├── Data/ # Remote Data Sources, Repositories mapping API responses
├── Domain/ # Business rules, Entities, and UseCases for API operations
├── Presentation/ # UI Components, ViewModels handling API states (loading/error/success)
├── Resources/ # Assets, fonts, and colors
└── Tests/ # Unit tests including API mocking
This project uses TMDB API.
You must add your own API key before running the project. Steps:
- Create an account on TMDB
- Generate your API key
- Open the file:
DI/DIContainer.swift - Add your API key:
@MainActor
public class DIContainer {
// Configurable API URL and Key
private let apiBaseURL = "https://api.themoviedb.org/3"
private let apiKey = "YOUR_API_KEY_HERE"
// ...
}- Clone the repository
git clone https://github.com/Coderkube-App/swiftui-api-integration.git- Generate Xcode Project
Ensure XcodeGen is installed (
brew install xcodegen).
xcodegen generate-
Open the project Open the generated
ios-swiftui-api-integration-boilerplate.xcodeproj. -
Run the app Select your target simulator/device and run the scheme (Cmd+R).
- Swift
- SwiftUI
- URLSession (HTTP client)
- XcodeGen
- Do not commit your API key to public repositories
- If API calls fail, check:
- Internet connection
- API key validity
- Rate limits
- Centralized Dependency Injection
- Separation of concerns (Clean Architecture: Domain, Data, Presentation)
- Repository Pattern
- Reusable network layer with typed errors
- Search movies
- Favorites or Watchlist
- Movie trailers
- Dark mode support
- Feel free to fork and improve this project
- Pull requests are welcome