Giter Site home page Giter Site logo

alexshepard84 / spacex-swiftui-demo Goto Github PK

View Code? Open in Web Editor NEW
10.0 1.0 0.0 4.74 MB

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.

Ruby 0.19% Swift 98.90% Makefile 0.91%
clean-architecture clean-code graphql graphql-api graphql-client restful-api spacex-api spacexapi spm swift

spacex-swiftui-demo's Introduction

SpaceX-SwiftUI-Demo

AppDemo

Overview

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.

Contributions

Feedback, suggestions, and contributions are welcome. Please use GitHub issues and pull requests.

Objective

This application is designed to showcase:

  • Swift and SwiftUI application development
  • Implementation of MVVM design pattern within Clean Architecture
  • Integration with RESTful and GraphQL APIs
  • Local data management using Core Data
  • Advanced SwiftUI features and animations
  • Unit and UI testing

Clean Architecture

Clean Architecture involves separating the code into layers, each with its distinct responsibility. This project is structured into:

  • Entities Layer: Contains the business logic models.
  • Use Cases Layer: Encapsulates the application-specific business rules.
  • Interface Adapters Layer: Comprises ViewModels, presenting data to the UI and handling user input.
  • Frameworks and Drivers Layer: Manages external dependencies and data sources, such as API services and databases.

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.

Features

SwiftShowcase includes:

  1. REST API Integration: Fetching and displaying data from RESTful services.
  2. GraphQL API Integration: Handling queries and mutations with GraphQL.
  3. Local Data Storage: Using Core Data for CRUD operations.
  4. SwiftUI Features: Implementing UI components.
  5. Testing: Unit and UI tests to validate code.

Architecture

The application uses a modular approach with Swift Packages, promoting code reusability and maintainability.

App Structure

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:

Domain Layer: SpaceXDomain (Swift Package)

  • Contains the core business logic and entities (models) of the application.
  • Defines interfaces (protocols) for repositories and use cases.

Data Layer: SpaceXRestApi (Swift Package)

  • Responsible for data retrieval and persistence.
  • Implements the repository interfaces defined in the SpaceXDomain package.
  • Interacts with external data sources, such as REST APIs.

Network Service: NetworkService (Swift Package)

  • A standalone package dedicated to handling network requests.
  • Provides a reusable and configurable service for making API calls.

App Layer

  • DIContainer: Manages the dependencies of the application, providing a centralized point for object creation and dependency injection.
  • PreviewDIContainer: A specialized version of 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.

Getting Started

Clone the repository and open the project in Xcode to begin:

git clone https://github.com/alexShepard84/SwiftShowcase.git

Project Setup

This section guides you through the initial setup process for the SwiftShowcase project.

Ruby Dependencies and Bundler

This project uses Bundler to manage Ruby dependencies, including CocoaPods and Fastlane.

Prerequisites

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

Installing Dependencies

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.

Using bundle exec

To ensure you are using the specific gem versions defined for this project, you should prefix commands with bundle exec. For example:

  • To run Fastlane lanes, use:
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.

Apollo GraphQL Setup

This project uses Apollo GraphQL for handling GraphQL queries. The setup process is streamlined using a Makefile.

Installing Apollo GraphQL CLI

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:

  • Installs the Apollo iOS CLI using Swift Package Manager in the Packages/Data/SpaceXGraphQL directory.
  • Downloads the latest GraphQL schema based on the configuration in Packages/Data/SpaceXGraphQL/Apollo/apollo-codegen-config.json.
  • Generates Swift code based on the GraphQL schema and operations defined in the project.

Updating GraphQL Schema and Code Generation

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

Troubleshooting

If you encounter any issues with the Apollo setup, ensure that:

  • The correct GraphQL endpoint and configurations are set in Packages/Data/SpaceXGraphQL/Apollo/apollo-codegen-config.json.

For more detailed information about Apollo GraphQL and its CLI, refer to the Apollo GraphQL documentation.

Acknowledgments

This project uses several third-party libraries and APIs:

SpaceX API

Data for this application is sourced from the SpaceX API, an open-source project providing comprehensive SpaceX data.

Third-Party Libraries

  • SwiftLint: A tool for enforcing Swift style and conventions. More information can be found at SwiftLint.
  • OHHTTPStubs: A library for testing HTTP requests and responses, available at OHHTTPStubs.
  • ApolloCombine: A library for integrating GraphQL with Swift's Combine framework, available at ApolloCombine.

Author

Alex Schäfer

spacex-swiftui-demo's People

Contributors

alexshepard84 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

spacex-swiftui-demo's Issues

Add Rocket Detail View

As a space enthusiast and app user,
I want to be able to view detailed information about each SpaceX rocket,
So that I can learn more about the specifications, history, and missions associated with each rocket.

Acceptance Criteria:

  1. Access to Detailed Information: When I select a rocket from the list of rockets, I should be taken to a detailed view that presents comprehensive information about the selected rocket.

  2. Display of Key Rocket Specifications: The detailed view should include key specifications of the rocket such as height, mass, payload capacity, first flight date, and engine details.

  3. Historical Context: The view should provide historical information about the rocket, including its development, maiden flight, and any notable missions it has been part of.

  4. Visual Elements: Where available, the view should include images or diagrams of the rocket to provide a visual context.

  5. Links to Additional Resources: If available, links to external resources such as articles, videos, or official SpaceX pages about the rocket should be provided for users seeking more in-depth information.

  6. User-Friendly Layout: Information should be presented in a clear, organized, and easy-to-navigate format, enhancing the overall user experience.

  7. Responsiveness: The Rocket Detail View should render effectively across different devices and screen sizes.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.