News Reader is an iOS application developed using SwiftUI that allows users to browse and read news articles from various sources. The app fetches articles from the NewsAPI, allows users to bookmark articles for offline reading of title and description, and provides filtering options for a personalized reading experience.
- iOS 17.0 or later
- Xcode 14.0 or later
- SwiftUI and SwiftData
News List | Bookmarked News List | News Detail |
![]() |
![]() |
![]() |
- Launch the app to view the latest news articles.
- Tap on an article to read its details.
- Bookmark articles by tapping the bookmark icon.
- Navigate to the Bookmarks tab to view saved articles.
The app supports localization for various strings to enhance user experience. All localizable strings are stored in the Localizable.strings file.
- Fetch News Articles: Retrieve articles from the NewsAPI based on user preferences.
- Bookmark Articles: Save articles locally for offline access.
- Read Full Content: View detailed information about each article.
- Filter Articles: Easily filter articles by category.
- Offline Access: Access bookmarked articles without an internet connection.
- User-Friendly Interface: A clean and intuitive design using SwiftUI.
- SwiftUI: For building the user interface.
- SwiftData: For local data storage of bookmarked articles.
- Network Framework: For monitoring internet connectivity.
The application follows the MVVM (Model-View-ViewModel) architecture pattern to separate concerns and enhance testability.
The main data model is NewsArticle
, which is represented as a SwiftData entity with the following properties:
id
: Unique identifier for the article.sourceName
: Name of the news source.author
: Author of the article.title
: Title of the article.articleDescription
: Brief description of the article.url
: Link to the article.urlToImage
: URL of the article's image.publishedAt
: Date the article was published.content
: Full content of the article.isBookmarked
: Boolean indicating if the article is bookmarked.
The NewsNetworkMonitor
class observes internet connectivity using the Network framework to notify users about connectivity changes.
The app implements error handling for network requests and database operations, ensuring that users are informed of any issues encountered.
The application includes unit tests written using XCTest. Tests cover:
- Validating the fetching of articles and their properties.
- Bookmarking and unbookmarking articles.
- Ensuring articles are correctly stored and retrieved from the database.
A mock version of ModelContext
, called MockModelContext
, is used to simulate database operations during testing, ensuring that tests do not affect real data.
Before executing tests that modify the database, the database is cleared to ensure each test runs in isolation. SWiftUI database is used to store offline bookmarked articles of title and description.
Clone the Repository git clone https://github.com/paulsoham/NewsReaderApp.git
This project is licensed under the MIT License - see the LICENSE file for details.
- Soham Paul - https://github.com/paulsoham