NewsApp is an iOS application built with UIKit that fetches and displays news articles from NewsAPI.org. The app supports browsing top headlines, filtering by category, and searching for news by keywords.
- Top Headlines: View the latest news headlines.
- Categories: Browse news by categories (e.g., General, Business, Technology).
- Search: Filter news articles by keywords.
- Image Loading: Display article images seamlessly.
- Xcode: 14 or later
- iOS: 17.4 or later
- Swift: 5
git clone https://github.com/olgazinchenko/NewsApp.gitNavigate to the project folder and open the Xcode project:
cd NewsApp
open NewsApp.xcodeprojThis project uses NewsAPI.org to retrieve news data. To keep your API key secure:
In your project, create a file named Secrets.xcconfig (make sure it’s not tracked by Git—add it to your .gitignore):
API_KEY = YOUR_NEWSAPI_KEY_HEREIn your Info.plist, add the following key-value pair to reference the API key from the xcconfig file:
<key>API_KEY</key>
<string>$(API_KEY)</string>In your ApiManager.swift, load the API key like this:
private static let apiKey: String = {
guard let key = Bundle.main.object(forInfoDictionaryKey: "API_KEY") as? String, !key.isEmpty else {
fatalError("API_KEY not set in Info.plist")
}
return key
}()Add Secrets.xcconfig to your .gitignore to prevent accidental commits of your API key:
Secrets.xcconfigAfter configuring your API key, build and run the app on the iOS Simulator or a physical device using Xcode.
- Browse News: The main screen displays top headlines for the selected category.
- Search News: Use the search bar to find articles by keywords.
- Read Articles: Tap on an article to view its details.
Contributions are welcome! If you have suggestions or bug fixes, please fork the repository and submit a pull request.
This project is licensed under the MIT License.
- NewsAPI.org for providing a free API to access news data.