Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent Lifecycle Timing of .introspect Execution on iOS 17 vs iOS 18 #445

Open
2 tasks done
dasilvans opened this issue Dec 24, 2024 · 0 comments
Open
2 tasks done
Labels
bug Something isn't working

Comments

@dasilvans
Copy link

Description

Hi, I am observing differences in the lifecycle timing of .introspect execution when upgrading from iOS 17 to iOS 18. Specifically, the order in which .introspect is executed relative to other view modifiers or lifecycle events (like .task) appears to have changed.

Here’s an example (though this issue also arises in other contexts):

ScrollView(.horizontal) {
    // Scroll view content
}
.introspect(.scrollView, on: .iOS(.v16...)) { scrollView in
    // Setup UIScrollView
}
.task {
    // Logic dependent on UIScrollView setup
}

iOS 17 Behavior: .introspect is called earlier in the view’s lifecycle, so the UIScrollView setup is completed before .task is executed.
iOS 18 Behavior: .task is executed first, and .introspect is called afterward, leading to cases where the UIScrollView is not yet set up when the .task logic runs.

This timing inconsistency creates challenges for logic that depends on .introspect being executed before other lifecycle events.

Checklist

Expected behavior

The .introspect modifier should ideally execute consistently at the same lifecycle stage across iOS versions, ensuring predictable behavior.

Questions
1. Is this a known change in the way .introspect interacts with SwiftUI lifecycle events in iOS 18?
2. Are there any suggested patterns or best practices to ensure that .introspect executes at the desired lifecycle stage, regardless of the iOS version?
3. Has anyone else experienced similar timing inconsistencies with .introspect or other modifiers, and if so, how did you address them?

Thank you for your help!

Actual behavior

No response

Steps to reproduce

No response

Version information

No response

Destination operating system

No response

Xcode version information

No response

Swift Compiler version information

No response

@dasilvans dasilvans added the bug Something isn't working label Dec 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant