After getting impatient with a "SwiftUI for Designers" course I decided to fuck around and find out.
Just hours after asking my 1st question: "Are you familiar with SwiftUI?" the core functionality of this app (an exercise utility) was up and working.
I've spent the past week tweaking the UI with small animations and features. It's a humble tool (local storage only) but I am nonetheless floored with how GPT has allowed me to completely skip the "learning syntax" part of development and ship something that I actually use.
Not only did it lower the syntax bar virtually to 0... I've learned just as much or more syntax from reading and debugging GPT outputs than I would by taking a course.
For fairness: I'm a design cofounder and self-taught React Native front-ender with 2 years of total experience in software (0 Swift). I am not a data structures person.
After working with ChatGPT to get the file structure and skeleton components set up over the span of ~3 days, I decided to scrap our previous data structure and propose a new one after realizing our first was too brittle to build certain components that I wanted.
Below is the prompt which resulted in the current data structure and functionality of the app, which is live on TestFlight for anyones use:
////////// PROMPT //////////
You are a full-stack iOS developer using SwiftUI. Together we are going to write the code for a two-tab exercise app which stores data locally using AppStorage and UserDefaults.
The app takes individual exerciseEntries which have a name and a count, and sorts these into groups called exerciseGroups.
ExerciseGroups are defined as any set of exerciseEntries which have the same name and occur with no more than 30 minutes between consecutive exerciseEntries.
On the first tab of our app, users input each exerciseEntry. On the second tab, they view their historical data. The first tab of the app is already complete, and we now only need to write the logic which occurs when a new exerciseEntry is submitted.
When a user submits an exerciseEntry, three arrays stored in AppStorage should simultaneously update with the correct data:
Exercises[], which contains an array of all exerciseEntries the user has submitted
ExerciseGroups[], which contains an array of all exerciseGroups
Days[], which contains an array of days
The data model is defined in a separate Swift File called ExerciseDataModel.swift:
public var exerciseTypes = ["Push Ups", "Pull Ups", "Chin Ups", "Squats", "Calf Raises"]
// ExerciseEntries
struct ExerciseEntry: Identifiable {
var id = UUID()
var exerciseName: String
var count: Int
var timestamp: Date
}
// ExerciseGroups
struct ExerciseGroup: Identifiable {
var id = UUID()
var groupName: String
var entries: [ExerciseEntry]
var startTime: Date
var duration: TimeInterval
}
// ExerciseTotals
struct ExerciseTotal: Identifiable {
var id = UUID()
var exerciseName: String
var total: Int
var date: Date
}
// Days
struct Day: Identifiable {
var id = UUID()
var date: Date
var exerciseGroups: [ExerciseGroup]
var totalCounts: [ExerciseTotal]
}
Based on this information, can you write a function that correctly updates the data in AppStorage after each time a user submits a new exerciseEntry?
I would suggest that this function first updates the Exercises[] array, followed by the ExerciseGroups[] array, and finally the Days[] array based on the logic defined above.
////////// END PROMPT //////////
It sounds like most of the benefit you got from ChatGPT lines up with deficits in your tooling. It's interesting that a language model set to "predict" can make up for that deficit for such a wide variety of languages! (Though it's no good for niche or more-than-slightly technical scenarios, like Vulkan programming; past a certain point, you need the actual tools to exist.)