How to build a water reminder app with Xcode and AI

Team Alex · April 6, 2025

Tutorial

Estimated completion time: 3 min read

How to build a water reminder app with Xcode and AI

In this tutorial, we're going to build a water reminder app using Xcode, Swift, SwiftUI, and a helpful AI assistant named Alex. By the end, you'll have a fully functional app that'll remind you to drink water throughout the day.

Overview

What We're Building

A water reminder app that allows users to:

  • Set a daily water intake goal.
  • Log the amount of water they drink.
  • Receive reminders to drink water.

We're using SwiftUI for the user interface, Swift for the app logic, and UserDefaults for data persistence. Our AI assistant, Alex, will help us streamline the development process.

Prerequisites

Implementation Steps

1. Project Setup & Planning

Create a new Xcode project and name it 'WaterReminder'. Choose SwiftUI for the interface and Swift for the language.

Next, let's plan out the app features:

  • GoalSettingView: A view where users can set their daily water intake goal.
  • LogWaterView: A view where users can log the amount of water they've drunk.
  • RemindersView: A view to display reminders.

At this point, we can talk to Alex and describe our views. For example, we can say "Alex, I need a view with a numeric input field for the daily water intake goal", and Alex will generate the SwiftUI code for this view.

2. Core Features

We'll start with the GoalSettingView. Let's create a state variable for the water goal and bind it to a TextField. Here's what the code looks like:

struct GoalSettingView: View {
    @State private var waterGoal = ""
    
    var body: some View {
        TextField("Enter your daily water goal in liters", text: $waterGoal)
            .keyboardType(.decimalPad)
    }
}

Then we'll add the LogWaterView and RemindersView in a similar manner.

With Alex, you can simply describe what you need. For instance, for LogWaterView, you can say "Alex, create a view with a slider from 0 to 10 and a button to log the water intake", and Alex will generate the SwiftUI code for you.

3. Data & Storage

For data persistence, we'll use UserDefaults. We need to save the water goal, the amount of water drunk, and the reminders.

Alex can help generate the boilerplate code for saving and retrieving data. You can ask "Alex, create a function to save the water goal in UserDefaults" and Alex will provide the necessary Swift code.

4. Polish & Refinement

Finally, to elevate the user experience, let's add some animations, handle loading and error states, and make some performance tweaks.

As you polish and refine your app, Alex can provide suggestions to improve your code structure or optimize any redundant logic.

Next Steps

In the next tutorial, we'll expand our app's functionality by adding notifications for the reminders and creating a user-friendly dashboard to track water intake throughout the day.

Conclusion

Congratulations! You've built a water reminder app using Xcode, Swift, SwiftUI, and Alex. You've learned how an AI assistant like Alex can streamline the app development process, from helping with UI development to simplifying data persistence.

Remember, Alex is there to assist you, whether you're a beginner or an advanced iOS developer. Give Alex a try. Happy coding!