Migrate from ObservableObject to @Observable (Swift Observation) - #653
Merged
IvanStepanok merged 65 commits intoMar 17, 2026
Conversation
Fix/issue 581
Migrated Course Unit View, CourseContainerViewModel, SignInViewModel, BaseCourseViewModel
Swift, replacing `@ObservedObject` and `@StateObject`. This modernizes the data flow and simplifies the code by leveraging the compiler to automatically manage observation. Also it increases the minimum iOS deployment target to 17.0
Updates the iOS deployment target to version 17.0 in the project settings. Refactors the course outline and progress view to handle loading states correctly.
IvanStepanok
self-requested a review
March 16, 2026 18:33
IvanStepanok
approved these changes
Mar 17, 2026
IvanStepanok
left a comment
Contributor
There was a problem hiding this comment.
You’ve put in a tremendous amount of work! Thank you so much!
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #653 +/- ##
========================================
Coverage ? 0
========================================
Files ? 0
Lines ? 0
Branches ? 0
========================================
Hits ? 0
Misses ? 0
Partials ? 0 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
IvanStepanok
added a commit
that referenced
this pull request
Jul 31, 2026
Brings in 35 commits, notably the ObservableObject -> @observable migration (#653) and the connectivity fix for issue 581 (#635). Conflict resolutions: - Core/Core/Configuration/Connectivity.swift Both branches had independently implemented an offline debounce. Took develop's (notReachableDelay/notReachableTask): it verifies with a live request before declaring offline, and it assigns internetState, which the sandbox side never did -- develop's OfflineSnackBarView now reads .onChange(of: connectivity.internetState), so keeping the sandbox side would have left the snackbar permanently dead. Grafted the sandbox side's de-dupe guard onto internetState.didSet so the Combine subject stops re-emitting unchanged states. Dropped the now-orphaned scheduleOffline/cancelOfflineDebounce. - Course/.../Unit/Subviews/WebView.swift Took develop's: the init already resolves viewModel/connectivity into @State/let, so re-resolving from the DI container in body was stale pre-Observable code that also discarded the injected connectivity. - Theme/.../TextColor/TextSecondary.colorset/Contents.json Kept sandbox's: generated by "Sandbox (3)/apply_ios_theme.py" from theme.json (textSecondary #97A5BB / #79889F). Deliberate branding override of the upstream token update in #658. - OpenEdX.xcodeproj/project.pbxproj Kept sandbox's DEVELOPMENT_TEAM and CURRENT_PROJECT_VERSION.
IvanStepanok
added a commit
that referenced
this pull request
Jul 31, 2026
Brings in 35 commits, notably the ObservableObject -> @observable migration (#653) and the connectivity fix for issue 581 (#635). Conflict resolutions: - Core/Core/Configuration/Connectivity.swift Both branches had independently implemented an offline debounce. Took develop's (notReachableDelay/notReachableTask): it verifies with a live request before declaring offline, and it assigns internetState, which the sandbox side never did -- develop's OfflineSnackBarView now reads .onChange(of: connectivity.internetState), so keeping the sandbox side would have left the snackbar permanently dead. Grafted the sandbox side's de-dupe guard onto internetState.didSet so the Combine subject stops re-emitting unchanged states. Dropped the now-orphaned scheduleOffline/cancelOfflineDebounce. - Course/.../Unit/Subviews/WebView.swift Took develop's: the init already resolves viewModel/connectivity into @State/let, so re-resolving from the DI container in body was stale pre-Observable code that also discarded the injected connectivity. - Theme/.../TextColor/TextSecondary.colorset/Contents.json Kept sandbox's: generated by "Sandbox (3)/apply_ios_theme.py" from theme.json (textSecondary #97A5BB / #79889F). Deliberate branding override of the upstream token update in #658. - OpenEdX.xcodeproj/project.pbxproj Kept sandbox's DEVELOPMENT_TEAM and CURRENT_PROJECT_VERSION in the two conflicting hunks, but kept develop's IPHONEOS_DEPLOYMENT_TARGET bump 16.4 -> 17.0 across all 6 configurations: Core is now built for iOS 17.0, so leaving the app target at 16.4 fails to compile with "module 'Core' has a minimum deployment target of iOS 17.0".
IvanStepanok
added a commit
that referenced
this pull request
Jul 31, 2026
Brings in 35 commits, notably the ObservableObject -> @observable migration (#653) and the connectivity fix for issue 581 (#635). Conflict resolutions: - Core/Core/Configuration/Connectivity.swift Took develop's version verbatim. Both branches had independently implemented an offline debounce; develop's (notReachableDelay / notReachableTask) verifies with a live request before declaring offline and assigns internetState, which the sandbox side never did -- develop's OfflineSnackBarView reads .onChange(of: connectivity.internetState), so the sandbox side would have left the snackbar permanently dead. This branch carries only the sandbox design and AppStore build configuration, so it keeps no connectivity logic of its own. - Course/.../Unit/Subviews/WebView.swift Took develop's: the init already resolves viewModel/connectivity into @State/let, so re-resolving from the DI container in body was stale pre-Observable code that also discarded the injected connectivity. - Theme/.../TextColor/TextSecondary.colorset/Contents.json Kept sandbox's: generated by "Sandbox (3)/apply_ios_theme.py" from theme.json (textSecondary #97A5BB / #79889F). Deliberate branding override of the upstream token update in #658. - OpenEdX.xcodeproj/project.pbxproj Kept sandbox's DEVELOPMENT_TEAM and CURRENT_PROJECT_VERSION in the two conflicting hunks, but kept develop's IPHONEOS_DEPLOYMENT_TARGET bump 16.4 -> 17.0 across all 6 configurations: Core is now built for iOS 17.0, so leaving the app target at 16.4 fails to compile with "module 'Core' has a minimum deployment target of iOS 17.0".
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR migrates ViewModels from the ObservableObject protocol and
@Publishedproperties to the new Swift Observation macro@Observable.As part of this change, the project now targets iOS 17+ as the minimum deployment version, allowing us to rely on modern SwiftUI and observation APIs without backward-compatibility workarounds.
Motivation
ObservableObject +
@Publishedrequires a significant amount of manual work and is error-prone:properties must be explicitly marked as
@Published, it’s easy to forget to publish changes, objectWillChange is implicit and not type-safe.With iOS 17 as the minimum supported version, we can safely adopt Swift’s
@Observablemacro, which provides a compiler-generated, first-class observation mechanism that is:What changed
Before
After
Benefits
@Published, or manual change notifications.