Habit Tracker App
Build an iPhone app for building daily habits: create habits such as reading, exercising or drinking water, tick them off each day, and see your current streak and a calendar of the last weeks showing which days you did each habit. Habits can be daily or only on certain weekdays, and an optional daily reminder notification nudges you at a time you choose. Everything is saved on the phone with UserDefaults and Codable. It's a great first iOS app: you'll learn SwiftUI lists, forms and navigation, state with @State and @Observable, saving data with Codable and UserDefaults, date calculations with Calendar, and local notifications.
- Estimate
- ~8.5h
- Steps
- 6
- Completed by
- 0
- Proposed by
- codeseed.app
SwiftUI · UserDefaults
Project roadmap
- 01
Build the habit list
~1.5hCreate a SwiftUI app. Define a Codable Habit struct (id, name, a color, the weekdays it's scheduled on, creation date, and the set of dates completed) and an observable HabitStore class holding the habits, with a few sample habits. Show today's habits in a List with a checkbox button each, and the others marked as not scheduled today. Done when: the list shows sample habits, and tapping a checkbox marks it done for today.
- 02
Add and edit habits
~1.5hBuild a form (in a sheet) to create and edit a habit: the name (required, and not a duplicate), a color, and the weekdays (all by default). Add swipe to delete with a confirmation. Done when: habits can be added, edited and deleted from the list.
- 03
Calculate streaks
~1.5hWrite a function that calculates the current streak: the number of scheduled days in a row, going back from today (or yesterday, if today isn't done yet), where unscheduled days don't break the streak. Use Calendar for date math, comparing days rather than exact times. Show the streak with a flame icon next to each habit, and a calendar grid of the last 5 weeks on the habit's detail screen. Done when: streaks and the calendar match the ticked days.
- 04
Save to UserDefaults
~1hSave the habits as JSON with JSONEncoder into UserDefaults whenever they change, and load them at startup. If the saved data can't be read, keep a copy of it and start fresh with a warning instead of crashing. Done when: habits and their history survive closing and reopening the app.
- 05
Add a daily reminder
~1.5hAdd a settings screen with a reminder toggle and a time picker. Ask for notification permission with UNUserNotificationCenter when the user turns it on (explaining why), and schedule a repeating daily notification with UNCalendarNotificationTrigger, updating it when the time changes and removing it when turned off. Done when: a reminder appears at the chosen time, and turning it off cancels it.
- 06
Test it
~1.5hWrite unit tests for the streak calculation with fixed dates (weekday schedules, gaps, today not done yet and across month ends), and for saving and loading, including broken data. Done when: the tests pass.
Ready to build this?
Get a GitHub repo and start building. Your AI reviewer checks each step as you go.
Tech stack