
In this video, we’ll walk through a simple demonstration of the Location Tracker app built with SwiftUI and CoreLocation. You’ll see how the app works from a user’s point of view and understand what the core features are.
We’ll cover how the app:
Requests permission to access the user's location
Displays the current latitude and longitude on the screen
Updates automatically as the user’s location changes
Can be tested using the built-in location simulation in Xcode's iOS Simulator
You’ll also learn how to simulate location updates using predefined routes like “Apple” or “City Run” in the simulator, which makes it easy to test without needing a real device.
This video is ideal if you're just starting out and want to understand what the app does before diving into how it's built.
In this lecture, we’ll walk through the most important methods and delegate callbacks provided by CLLocationManager, the central class used to access location data in iOS.
You'll learn how to request location permissions from users, start and stop location tracking, and request one-time updates. We’ll also explore how to check whether location services are enabled on a device—an essential step for robust apps.
Equally important, we’ll explain how the delegate system works, and which methods you need to implement to receive location updates, handle errors, and respond to changes in user permission.
By the end of this lecture, you’ll understand:
The difference between "always" and "when in use" location permissions
How to enable continuous or single-location updates
What each delegate method does and when it gets called
How to properly structure your location tracking logic using CoreLocation
In this lesson, we break down the LocationService class—your app’s dedicated engine for managing all location-related tasks in a SwiftUI project. You'll learn how this class fits into the MVVM architecture by cleanly separating location tracking logic from your user interface.
We walk through the key components of this class, including:
Importing and using CoreLocation and Combine
Initializing and configuring the location manager
Requesting permission to access the user's location
Starting and stopping location updates
Publishing live location data to other parts of your app
A key part of this lesson is understanding what a delegate is and how CLLocationManager uses the delegate pattern to notify your class of new location updates or errors. We explain how this pattern works in practice, and how your class responds by implementing methods like didUpdateLocations and didFailWithError.
By the end of this video, you'll have a solid grasp of how the LocationService class:
Requests location access from the user
Listens for and responds to GPS updates
Publishes location changes to your ViewModel
Integrates cleanly into a scalable SwiftUI architecture
This lesson is essential for anyone looking to implement real-time location features while keeping their codebase clean and maintainable.
Understanding `cancellables` and Subscriptions in the LocationViewModel
=======================================================================
In the LocationViewModel, `cancellables` is used to manage and clean up subscriptions to location updates using the Combine framework. To understand why this is necessary, it helps to first understand what subscriptions are.
What Is a Subscription?
-----------------------
A subscription is a connection to a data source that can send updates over time. In Combine, this typically involves a Publisher (data source) and a Subscriber (listener).
When you use `.sink` on a Publisher, you're telling the system:
"Send me updates whenever the data changes."
This connection continues until you cancel it, or the object managing it is destroyed. If you don't manage subscriptions properly, they can continue running and using memory or CPU unnecessarily, even if your app isn't using the data anymore.
What Are Cancellables?
----------------------
Combine provides a type called `Cancellable`, which represents an active subscription. When you no longer need updates, you can call `.cancel()` on a Cancellable to stop the data stream.
Why Use a Set of Cancellables?
------------------------------
In the ViewModel:
----------------------------------------
private var cancellables = Set<AnyCancellable>()
----------------------------------------
This line creates a collection that stores all active subscriptions. Combine will automatically cancel these when the ViewModel is deallocated, which ensures no leftover tasks are still running.
How It Works in This Code
--------------------------
Example from the ViewModel:
----------------------------------------
locationService.locationPublisher
.receive(on: DispatchQueue.main)
.sink { [weak self] location in
self?.userLocation = location
}
.store(in: &cancellables)
----------------------------------------
- `.sink` creates the subscription and listens to location updates.
- `.receive(on: DispatchQueue.main)` makes sure updates are sent on the main thread (required for UI changes).
- `.store(in: &cancellables)` keeps track of the subscription so Combine can cancel it when the ViewModel is destroyed.
Why This Matters
----------------
- Prevents memory leaks from subscriptions that are never canceled.
- Saves battery and performance by stopping unused data streams.
- Keeps your app clean, efficient, and easy to manage.
Summary
-------
- A subscription is a connection to a live data stream.
- A `Cancellable` lets you stop that connection when it's no longer needed.
- A `Set<AnyCancellable>` stores and manages these subscriptions.
- Combine automatically cancels stored subscriptions when the ViewModel is destroyed.
In this lesson, we explore the LocationViewModel—the key link between the location logic in your app and the SwiftUI user interface. Built within the MVVM (Model-View-ViewModel) architecture, this component helps keep your code clean, reactive, and well-organized.
We’ll walk through how the LocationViewModel:
Subscribes to live updates from the LocationService
Publishes the current user location to the SwiftUI view
Requests location permissions
Starts and stops GPS tracking as needed
You’ll learn about the tools that power this ViewModel, including:
@Published to trigger UI updates
ObservableObject to connect with SwiftUI’s data system
Combine’s .sink and AnyCancellable for managing subscriptions
We also demonstrate how the ViewModel listens for updates on the main thread and performs clean-up when it’s no longer in use.
By the end of this lesson, you’ll understand how the ViewModel:
Encapsulates your location-handling logic
Keeps your view layer simple and declarative
Supports testable, scalable app architecture
This lesson is essential for understanding how to properly separate concerns and manage reactive location data in a SwiftUI app.
In this lesson, we focus on the ContentView—the main user interface of the Location Tracker app. This view is responsible for presenting the user’s current location and reacting to updates from the ViewModel in real time.
You'll learn how the view connects to the LocationViewModel using @StateObject, a key SwiftUI feature that ensures your view properly subscribes to and responds to changes in observable data.
We’ll walk through:
The structure and logic of ContentView
How SwiftUI conditionally displays latitude and longitude
What happens when location data is loading or unavailable
How SwiftUI’s reactivity keeps the UI in sync with the latest location updates
This lesson also reinforces the principles of the MVVM architecture:
The ViewModel handles location permissions and data logic
The view remains simple, declarative, and focused on UI
By the end of this lesson, you'll understand how ContentView:
Subscribes to real-time updates using @StateObject
Displays location data cleanly and conditionally
Maintains a clean separation between UI and business logic
This is a great example of how to build responsive, location-aware interfaces using SwiftUI and MVVM.
In this hands-on coding session, we'll build a simple but powerful location tracker app using SwiftUI, CoreLocation, and Combine. You'll follow along step-by-step as we architect the app using the MVVM (Model-View-ViewModel) design pattern for clean, testable code.
We'll start by creating a LocationService to manage all CoreLocation logic and delegate callbacks. Then, we’ll wire that service into a LocationViewModel using Combine to stream real-time location updates to our SwiftUI views.
By the end of the lesson, your app will request permission, start tracking, and display the user's live latitude and longitude on the screen—reactively updating as the location changes.
What You’ll Learn:
How to integrate CoreLocation in a SwiftUI project
The role of delegates in handling location updates
How to expose location data through a Combine publisher
Binding updates from a ViewModel to the UI
Using MVVM to separate location logic from view logic
Simulating location data in the iOS Simulator
Whether you're new to location services or looking to improve your SwiftUI architecture, this lesson offers a practical and clean way to implement location tracking from scratch.
Just a short explanation of a passthrough subject.
This app is a demonstration of how SwiftUI integrates with CoreLocation and MapKit to display boxing gym locations on a map. When you launch the app, it loads a predefined list of boxing gyms in the Bay Area from a local JSON file. These gyms include basic information like name, address, business hours, and a mock rating.
At the top of the screen, there's a dropdown list (Picker) where you can select a gym. When you choose a gym, its location is shown on the map using a pin. Beneath the map, a small flyout displays the selected gym's name and business hours.
The map centers on the selected gym's coordinates, allowing users to visually locate it. The app uses SwiftUI's data-binding system to dynamically update both the map and the flyout details whenever a new gym is selected. There are no external API calls — all data is handled locally, making this ideal for testing or instructional purposes.
This demonstration is focused purely on UI interaction and map display, not on live location tracking or remote server communication.
The BoxingGym model conforms to Identifiable, Decodable, and Hashable to work smoothly with SwiftUI. Identifiable lets SwiftUI track each gym in lists and pickers. Decodable allows the app to load data from a JSON file. Hashable enables Swift to compare gyms, which is necessary for selections and state updates.
In this video, we build a mock service in Swift to simulate fetching boxing gym data asynchronously. You'll learn how the BoxingGymMockService class introduces a 3-second delay using Task.sleep to mimic a real network call. We explain how the service loads JSON data from a local file bundled with the app, and how this structure prepares your SwiftUI project for real-world API integration. This is an essential step for testing and development before connecting to live backend services.
In this video, we explore the creation of the GymListViewModel, a key part of managing gym data in our SwiftUI app. You’ll learn how this view model loads data asynchronously using a mock service, decodes it into an array of BoxingGymobjects, and sets the initial selection for display. We explain the use of @Published properties to enable reactive updates in the UI, the role of @MainActor in UI-bound async functions, and how Task initializes the data load when the view model is created. This video highlights how to bridge data loading with SwiftUI’s state-driven views using the MVVM pattern.
In this video, we walk through the process of building a SwiftUI view from scratch. You'll see how to structure the layout, bind data from a view model, and use conditional logic to update the UI dynamically. This demonstration highlights how SwiftUI’s declarative syntax and state management make building responsive interfaces straightforward and intuitive.
In this video, we break down the difference between using viewModel and $viewModel in a SwiftUI app. You’ll learn when to access the view model directly to read values or call functions, and when to use the dollar sign ($) to create bindings for two-way data flow. We walk through real examples using a gym selection interface, show how @StateObjectand @Published properties work together, and explain why binding to properties—not the entire view model—is typically the right approach. This is a key concept for building responsive and well-structured SwiftUI apps.
In this video, we walk through the process of building a SwiftUI view from scratch. You'll see how to structure the layout, bind data from a view model, and use conditional logic to update the UI dynamically. This demonstration highlights how SwiftUI’s declarative syntax and state management make building responsive interfaces straightforward and intuitive.
In this concise lesson, you'll learn how to control the visible region of a map using MapKit's MKCoordinateRegion and MKCoordinateSpan. These foundational types are essential for focusing the map on a specific location and adjusting the zoom level dynamically.
We'll explore how to define a region using a center coordinate (CLLocationCoordinate2D) and a span that determines how much area is shown. You'll see how to apply this in SwiftUI to ensure the map zooms appropriately to highlight key locations—like the selected gym in a fitness app.
In this lesson, we dive into how SwiftUI responds to changes in state and view lifecycle events using a real-world MapView example. You'll learn how .onAppear initializes the view, how .onChange tracks updates to deeply nested properties like CLLocationCoordinate2D, and why a wrapper like EquatableCoordinate is necessary. We also cover how user interaction is handled with .onTapGesture. This explanation helps solidify your understanding of SwiftUI's reactive architecture and prepares you to build dynamic, location-aware interfaces.
In this video, we walk through the process of building a SwiftUI view from scratch. You'll see how to structure the layout, bind data from a view model, and use conditional logic to update the UI dynamically. This demonstration highlights how SwiftUI’s declarative syntax and state management make building responsive interfaces straightforward and intuitive.
In this video, we demonstrate the GymSearch app—a SwiftUI-powered application that lets users enter a ZIP code and instantly find gyms within a 5-mile radius. Using MapKit and CoreLocation, the app performs a location-based search, drops pins for nearby gyms, and displays them in a list format. You'll see how the app captures user input, performs asynchronous searches using a decoupled geolocation service, and dynamically updates the UI with gym results. Perfect for learning how to build location-aware apps using modern SwiftUI architecture and Apple's mapping tools.
In this video, you'll learn how to build the Gym Search app from the ground up using SwiftUI, MapKit, and CoreLocation. We'll walk through creating a clean MVVM architecture, including a ViewModel that handles user input and interacts with a decoupled GeoSearchService. You'll see how we structure the data using a custom IdentifiableMapItem to make gym locations compatible with SwiftUI views. By the end of this tutorial, you'll understand how to perform local searches based on ZIP code input, handle asynchronous map searches, and display the results in a SwiftUI interface. Perfect for developers looking to master geolocation and map integration in iOS apps.
This video explains why the IdentifiableMapItem struct is used in SwiftUI when working with map search results. Since MKMapItem—which represents points of interest like gyms—does not conform to the Identifiable protocol, it can’t be used directly in SwiftUI views like List or ForEach. IdentifiableMapItem wraps each MKMapItem with a unique ID, making it compatible with SwiftUI’s data-driven UI system. This ensures smooth rendering and updates of views that display search results.
Are you ready to build modern, scalable location-based apps with SwiftUI? This course will teach you how to harness the power of CoreLocation and MapKit, while applying the MVVM architecture pattern to create clean, maintainable, and testable code.
In this hands-on course, you’ll learn how to track user location in real time, display it on interactive maps, drop custom pins, request location permissions properly, and simulate location changes using Apple’s development tools. But we won’t stop at basic implementations — you’ll architect everything using the MVVM pattern, ensuring a clear separation of concerns between your view, business logic, and location services.
You’ll begin with the fundamentals of geolocation in iOS, then progressively build more advanced features such as live location tracking, map annotations, location simulation, and saving coordinates. Every lesson is grounded in real-world use cases, so you're building practical skills you can use in production.
By the end of the course, you’ll have created a fully functional MyLocationTracker app, structured to scale and designed with professional SwiftUI practices. Whether you're a SwiftUI beginner expanding into location features, or an experienced iOS developer refining your architecture, this course delivers practical, production-level skills.
Topics include:
CoreLocation fundamentals and permission handling
MapKit integration with SwiftUI
MVVM design pattern for location-based features
Real-time location tracking and annotation management
Simulating and testing location in Xcode’s iOS Simulator
Enroll today and learn how to build clean, powerful location-aware apps the right way.