Build a Currency Converter App using Swift & SwiftUI by integrating a real-time exchange rate API.
Click on the Fork button on the top right of this repository.
git clone https://github.com/Google-Developers-Group-IIIT-Lucknow/DevSphere-App-iOS-Medium.git- Open Xcode
- Click on Open a Project
- Select the cloned folder
Navigate to logic.swift and implement the following:
API Endpoint:
https://open.er-api.com/v6/latest/{BASE_CURRENCY}
Example:
https://open.er-api.com/v6/latest/USD
What to implement:
- Make an API call using
URLSession - Decode the response into
ExchangeRateResponse - Store the rates in the
ratesdictionary - Handle loading state using
isLoading - Handle errors using
errorMessage
What to implement:
- Take the input amount
- Convert from
fromCurrencytotoCurrency - Use the exchange rates fetched from the API
Formula:
Converted Amount = Amount × (To Currency Rate / From Currency Rate)
| Property | Value |
|---|---|
| Base URL | https://open.er-api.com |
| Auth | No API key required |
| Endpoint | /v6/latest/{BASE_CURRENCY} |
- Fetch real-time exchange rates from the API
- Implement correct conversion logic
- Handle invalid inputs properly
- Show loading and error states
- Keep code clean and readable
❌ Do NOT hardcode exchange rates
✅ Always use live API data
🔄 Ensure conversion updates correctly when inputs change
Currency_Converter/
├── logic.swift ← Your implementation goes here
├── ContentView.swift
├── Config.swift
└── ...
- Fork the repository
- Create your branch:
git checkout -b your-branch-name - Commit your changes:
git commit -m "implement currency converter logic" - Push to the branch:
git push --set-upstream origin your-branch-name - Open a Pull Request