Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Open
Labels
bugSomething isn't working
@dasilvans

Description

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /