An app to hit the NY Times Most Popular Articles API and:
- Show a list of articles
- Shows details when items on the list are tapped.
The most viewed section of this API is used in the app. http://api.nytimes.com/svc/mostpopular/v2/mostviewed/{*section*}/{*period*}.json?apikey= sample-key To test this API, For testAPI we used:
- section - "all-sections"
- period - 7
MVVM Design pattern and swift generic approach to develop this application is used. For CI/CD Fastlane is used.
- Installation by cloning the repository
- Open terminal and navigate to project directory.
- Run
pod install
- Open NYTimesArticles.xcworkspace
Fastlane has been used to perform following tasks with a help of a script written in Fastfile. Gemfile is used to define your dependency on fastlane.
Tasks:-
- Downloading dependency of projects mentioned in Podfile
- Build the project
- Linting
- Run unit tests and code coverage
Execution:-
- Open terminal and navigate to project directory.
- Run
bundle exec fastlane integrate
Results:-
- Build - Archive is created in ~/NYTimesArticles/build-dir.
- Tests - Test report is generated at
~/NYTimesArticles/fastlane/test_output/report.html
- Lint - Lint report is generated at
~/NYTimesArticles/fastlane/swiftlint.result.json
- Code Coverage - Code coverage is generated at
~/NYTimesArticles/fastlane/test_output/code_coverage/index.html
This is also another tool integrated for check project code health reports.
- Project already contains
run-sonar-swift.sh
andsonar-project.properties
in project root folder. - Once your server up, goto project directory.
- Run the command from project directory using terminal
$ sh run-sonar-swift.sh
- On successful results, open browser and hit
http://localhost:9000/
, - You will see the project analyses, Tap on project analyses it will show detail reports
- ArticleListViewController - It displays most popular articles in a table view.
- ArticleDetailViewController - Displays article details in a scroll view.
- ArticleListViewModel - Initialised with an instance conforming to ArticleFetcherProtocol protocol. It is responsible for fetching articles and updating ArticleListViewController
- ArticleTableViewCellViewModel - Initialised with Article, responsible for displaying data in ArticleTableViewCell
- ArticleDetailViewModel - Initialised with Article, responsible for displaying data in ArticleDetailViewController