Skip to content
AgileLogics
Intermediate 5 min read

Intermediate Projects

Prerequisites: Level 2 — Intermediate

Build these using structs, enums, protocols, error handling, Codable, networking, and Swift packages from Level 2. Give each project its own Swift package (swift package init) with tests.

1. Expense Tracker

Model an Expense struct (amount, category enum, date) that conforms to Codable. Save and load expenses as JSON in a file, and print a monthly report grouped by category with Dictionary(grouping:by:). Throw a custom error for invalid amounts, and cover the logic with tests.

2. Weather Command-Line App

Call a free weather API with URLSession and async/await, decode the JSON response into Decodable structs, and print the current temperature for a city passed as a command-line argument (CommandLine.arguments). Handle network errors and non-200 responses gracefully.

3. Contact Book Library

Build a ContactBook library target with search, sorting, and email validation, plus a separate executable target that uses it. Mark only the types callers need as public.

4. Shapes and Protocols

Define a Shape protocol with area and perimeter, implement it for several shapes (structs), and write generic functions that work with any array of shapes — total area, the largest shape, shapes sorted by perimeter.