Repeated concurrency compiler warnings

Hi,

I have a Swift project which has 149 warnings. I am a bit confused as to why warnings are shown in unrelated files and many of them are the same warnings repeated a number of times.

Environment:

  • Xcode Version 14.3 (14E222b)
  • macOS: 13.3.1 (a) (22E772610a)
  • Build setting: swift strict concurrency is turned on

Questions:

  • Am I missing something?
  • Is there a way to fix these warnings? (As it seems as a big distraction from other warnings)

Problem 1:

40 compiler warnings correspond to the warning message:

Non-sendable type 'Notification?' returned by call from main actor-isolated context to non-isolated instance method 'next()' cannot cross actor boundary
  • These are thrown on files which are not using Notification at all
  • I have removed returning a notification
  • I don't have a function called next() in my project / swift packages I use.
  • I have quit the project, cleared DerivedData, cleaned build folder (Command Shift K) and re-compiled still I see the 40 same warnings

Problem 2:

Over a 100 of them correspond to the following warning:

Cannot form key path that captures non-sendable type 'KeyPath<AttributeScopes.SwiftUIAttributes, AttributeScopes.SwiftUIAttributes.ForegroundColorAttribute>'

The code responsible for this warning is:

func f1() {
    var attributedString = AttributedString("This is a green car.")
    let range = attributedString.range(of: "green")!
    
    //Warning: ContentView.swift Cannot form key path that captures non-sendable type 'KeyPath<AttributeScopes.SwiftUIAttributes, AttributeScopes.SwiftUIAttributes.ForegroundColorAttribute>'
    attributedString[range].foregroundColor = .green
}
  • I am using this code, but I have used ForegroundColorAttribute only in 2 functions, yet I get 110 compiler warnings.
  • Feedback: FB11748376

Problem 3:

Using @preconcurrency import SwiftUI shows the following warning:

'@preconcurrency' attribute on module 'SwiftUI' is unused
  • Should all occurrences of import SwiftUI be replaced by the above or just 1?