A simple iOS App that reads from the Test Flight News API

Overview

README

Table of contents

General info

SpaceFlight is a simple app built using the MVVM design pattern which reads from the SpaceFlight API. SpaceFlight supports both Dark Mode and Light Mode based on the system settings with the theme accent color of the app being systemRed. The UI was built primarily using UIKit while some cells were built using SwiftUI. All of the network requests used URLSession to reduce the dependency of using Cocoapods or any other framework. I created a custom UIImageView class called CustomImageView which handles the UIActivityIndicatorView and caches images.

Generated Code

In the first revision of SpaceFlight, I used PostMan to test the API get requests for the fetchArticles function in the SpaceFlightModelView. I integrated the generated code from PostMan but have since then completely rewritten the function to better handle returned errors, invalid responses, and invalid data.

Another part of the generated code I rewritten was the model for Articles. I used quicktype.io to convert JSON objects into Swift Models to allow for the model to be used as a Codable object. It tends to work well but usually returns a model object that has too many properties that are not needed. I have rewritten the model to store the properties of the API that are being used. This helped clean up the code significantly and reduced the property size of the Article model.

Unit Testing

Although I am very new to Unit testing, I watched a WWDC video and did my best to integrate a MockClass that will return expected data. Which would allow for testing in the Unit Test much cleaner. I created two Mock classes using protocols. One that tests the SpaceFlight API and the other tests the CustomImageView class.

Technologies

Project is created with:

  • UIKit
  • SwiftUI
  • URLSession for network requests
  • Space Flight API

Revision Updates

Here is a list of updates I made for this revision:

Networking

  • Blocks the main thread while waiting for networking to complete while app appears frozen on a black screen
  • Make sure the app behaves well without a network connection
  • Fix the app hanging while waiting for the network response

Design

  • Make the code style consistent throughout and consistent with the Swift API Design Guidelines
  • Some naming inconsistencies
  • Some whitespace inconsistencies
    • Remove space before an opening parenthesis in function or method declarations and invocations
    • Opening braces should be preceded by a single space
    • Vertical whitespace should be limited to a single empty line.
    • Vertical whitespace should be used consistently in between top level declarations and in between members of those declarations
    • Write a documentation comment for every declaration, following the Swift API Design guidelines
    • Avoid abbreviations
    • Avoid force unwrapping and force casts.
    • Return arrow and return type should be separated by a single space or on a separate line.
    • There should be no space before and only one space after any comma.
    • White space before and after colons should be consistent throughout
    • Lines should not have trailing whitespace.
    • Lines longer than 120 characters should be broken up
    • Follow case conventions. Names of types and protocols are UpperCamelCase. Everything else is lowerCamelCase.
    • // MARK comments, if creating a separator, should include a single space before and after the hyphen
    • Remove duplicate imports
  • No README or top level documentation
  • No loading indicators
  • Print statement should be removed

Tests

  • Include some unit tests that do not test the golden path, e.g. error and edge cases
  • Tests are minimal and do not pass
  • Tests rely on the current date
  • Make sure the tests pass, even without a network connection

Setup

This project contains no dependencys. Works right out of the box.

You might also like...
NewsApp- - Built A News App With SwiftUI and Mock Data
NewsApp- - Built A News App With SwiftUI and Mock Data

News APP Built A News App With Swift UI and Mock Data Screen Gif

News App 📱 built to demonstrate the use of SwiftUI 3 features, Async/Await, CoreData and MVVM architecture pattern.
News App 📱 built to demonstrate the use of SwiftUI 3 features, Async/Await, CoreData and MVVM architecture pattern.

Box Feed News App 📱 built to demonstrate the use of following features, SwiftUI 3 Async/Await AsyncImage List Refreshable Swipe Actions Separator Cor

A mobile application that presents the news received via NewsAPI to the user. Built with SwiftUI.
A mobile application that presents the news received via NewsAPI to the user. Built with SwiftUI.

📰 SwiftUI News App with NewsAPI A mobile application that presents the news received via NewsAPI to the user. Built with SwiftUI. ✅ Features The data

 News! LivefrontCodeChallenge
News! LivefrontCodeChallenge

News! LivefrontCodeChallenge This app uses the NYT API to fetch and display popular aticles. You can filter between popular articles today, last 7 day

Headline News Widget for Better Touch Tool. You can display the articles fetched by rss.

BTTPluginHeadLineNews This is a headline news widget plugin for BTT(Better Touch Tool) You can display the articles fetched by rss. (Pock version is h

Project developed as part of a test task by RentaTeam
Project developed as part of a test task by RentaTeam

RentaTeamGiphy Project developed as part of a test task by RentaTeam. There is "endless" prefetching gallery of giphy preview pictures with play video

Free Market Selection Process Test
Free Market Selection Process Test

Prueba Proceso de Seleccion Mercado Libre (Xcode Version 13.0, iOS 15) Caracteristicas de la App SearchPortrait SearchLandscape DetailPortrait DetailL

The demo project to show how to organize code to make SwiftUI apps easy to be test.
The demo project to show how to organize code to make SwiftUI apps easy to be test.

TestableApp I combined the idea to use functional programming instead of an loader instance in ModelView(I prefer to think of it as a service) and Res

Mac-asksec - Test Mac Permissions from the Terminal

asksec A simple CLI to test permissions from any macOS terminal app. Building ru

Owner
Diego Bustamante
A iOS and Django Developer
Diego Bustamante
A SwiftUI app that reads iOS/watchOS/tvOS device model information from Xcode you select.

iVariant A SwiftUI app that reads iOS/watchOS/tvOS device model information from Xcode you select. Preview License iVariant is licensed under MIT. Cop

Lakr Aream 20 Aug 4, 2022
Easily create UIViewControllers for news articles similar to those in the News app.

MRArticleViewController This framework allows you to easily setup View Controllers to display News Articles inspired by those from the Apple News App.

Matt Rigdon 104 Apr 18, 2022
App for displaying VK news feed (VKSDK API). Clean Swift VIP architecture

VKNewsFeed VKNewsFeed - application for displaying VK news feed with dynamic cells and a collection of images in the post. Data request occurs from th

Areg Vardanian 0 Dec 18, 2021
NewsAPI-Project - News API Project For iOS

NewsAPI-Project Es necesario descargar y realizar un pod install para ejecutar e

Álvaro Ferrández 0 Feb 3, 2022
Simple news iOS app with SwiftUI

NewsUI Simple news iOS app with SwiftUI ??️ which uses NewsAPI to fetch top news headlines The codebase uses following modern keys: SwiftUI Async/Awai

Fumiya Yamanaka 19 Dec 22, 2022
EzNews - A simple and easy to use News app for iOS and iPadOS. It uses NewsAPI as its backend

EzNews This was my first proper Swift app. Its a news app made for iOS and iPadO

Arnav Singhal 4 Apr 30, 2022
MyNews-iOS - A simple iOS mobile application for reading news articles

MyNews A simple iOS mobile application for reading news articles. This app uses

Ernest Nyumbu 1 Mar 31, 2022
App Everything in one place (news, weather, stocks and much more)

Dashy Everything in one place (news, weather, stocks and much more) I tried to follow MVVM Pattern, Used Decodable And URLSession instead of thrid-par

Aayush 3 Nov 24, 2021
A News Feed App Built With Swift

News Feed App TabBarController'ımızın ilk tabında "newsapi.org"dan gelen veriyi kullanıcıya gösteriyoruz. Başlangıç url'indeki sonuçları gösteren sayf

Hasan Ali 2 Oct 24, 2022
Flutter news app with NewsApi Org

Installation flutter pub get Usage flutter run Learn I will show how to create a flutter news app with NewsApi Org, In Flutter News App we will load

Sanskar Tiwari 378 Jan 1, 2023