SwiftShowcase: An iOS app that demonstrates modern Swift development with clean architecture. Includes examples of REST and GraphQL API integrations with the SpaceX API, implemented in a modular, testable and maintainable code base.
SwiftShowcase is an iOS application that demonstrates advanced development techniques in Swift and SwiftUI, focusing on both RESTful and GraphQL API integrations. The project adheres to Clean Architecture principles to ensure maintainability, scalability, and separation of concerns.
Feedback, suggestions, and contributions are welcome. Please use GitHub issues and pull requests.
This application is designed to showcase:
Clean Architecture involves separating the code into layers, each with its distinct responsibility. This project is structured into:
This layered approach ensures that the application is not only testable and independent of external frameworks but also that business logic and UI are decoupled.
SwiftShowcase includes:
The application uses a modular approach with Swift Packages, promoting code reusability and maintainability.
The application is structured into several layers and packages, each with a specific role in the overall architecture. Below is an overview of the main components:
SpaceXDomain
(Swift Package)SpaceXRestApi
(Swift Package)SpaceXDomain
package.NetworkService
(Swift Package)DIContainer
used for SwiftUI previews. It typically provides mock implementations for testing and UI development purposes.Each layer is designed to be independent and interchangeable, promoting a clean architecture that separates concerns and enhances testability.
Clone the repository and open the project in Xcode to begin:
git clone https://github.com/alexShepard84/SwiftShowcase.git
This section guides you through the initial setup process for the SwiftShowcase project.
This project uses Bundler to manage Ruby dependencies, including CocoaPods and Fastlane.
Ensure you have Ruby installed on your system. The required Ruby version is >= 2.6.3 and <= 3.2.2. You can check your Ruby version with ruby -v
.
If Bundler is not already installed, install it using:
gem install bundler
To install all required Ruby gems, run the following command in the project directory:
bundle install
This will install the gems defined in the Gemfile
.
bundle exec
To ensure you are using the specific gem versions defined for this project, you should prefix commands with bundle exec
. For example:
bundle exec fastlane [lane_name]
Using bundle exec
ensures that you are using the correct versions of the gems set for this project and avoids conflicts with other gem versions that may be installed globally on your system.
This project uses Apollo GraphQL for handling GraphQL queries. The setup process is streamlined using a Makefile.
The Apollo GraphQL CLI is essential for downloading the GraphQL schema and generating Swift code from GraphQL files. The CLI is installed and managed via the Makefile.
To install the Apollo GraphQL CLI and set up the necessary configurations, run:
make setup
This command performs the following actions:
Packages/Data/SpaceXGraphQL
directory.Packages/Data/SpaceXGraphQL/Apollo/apollo-codegen-config.json
.To update the GraphQL schema or regenerate Swift code after making changes to GraphQL queries or mutations, run the following commands:
make fetch-schema
make generate
If you encounter any issues with the Apollo setup, ensure that:
Packages/Data/SpaceXGraphQL/Apollo/apollo-codegen-config.json
.For more detailed information about Apollo GraphQL and its CLI, refer to the Apollo GraphQL documentation.
This project uses several third-party libraries and APIs:
Data for this application is sourced from the SpaceX API, an open-source project providing comprehensive SpaceX data.
Alex Schäfer