Xcode 15.3 RC issues warnings for generated code

The RC of Xcode 15.3 gives me warnings for generated code when String Concurrence Checking is set to complete:

@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
extension DeveloperToolsSupport.ColorResource {

    /// The "AccentColor" asset catalog color resource.
    static let accent = DeveloperToolsSupport.ColorResource(name: "AccentColor", bundle: resourceBundle)

}

The warning:

Static property 'accent' is not concurrency-safe because it is not either conforming to 'Sendable' or isolated to a global actor; this is an error in Swift 6

Does anyone else have this problem?

This is due to SE-0412: Strict concurrency for global variables, which was added in Swift 5.10. It requires that

Under strict concurrency checking, require every global variable to either be isolated to a global actor or be both:

  1. immutable
  2. of Sendable type

Since that variable is for an asset, I suspect that isolating it to @MainActor would be sufficient here.

@jmjauer Is this the code generated by Xcode to access asset catalog resources, or your own generated code? If it's Xcode's you'll want to report it to Apple to see if it can be fixed, and we'll want to notify some people here.

@allevato A better solution would likely be to make the ColorResource (and other resource types, presumably) Sendable, as they're just dumb containers, so that they can be used regardless of actor. These keys are often passed around various contexts before being used in the UI.

1 Like

Sure, but DeveloperToolsSupport is an Apple SDK framework, so I offered the solution that was more immediately feasible without adding unchecked retroactive conformances.

(Of course, if the code is generated by Xcode, then my suggestion also won't work.)

I don't believe you can edit the code from Xcode's generator (it's a build time generator, like macros, and doesn't put code on disk for the project) anyway. It is cached in DerivedData (Build/Intermediates.noindex/{target}.build/Debug-iphonesimulator/{target}.build/DerivedSources/GeneratedAssetSymbols.swift) so you might be able to copy it out, but this is mostly an Apple problem to fix.

2 Likes

Yes, it is generated by Xcode. I will report it.

It is generated by Xcode - I was just surprised that an obvious bug that generates a warning for pretty much every project is still in the RC of Xcode.

3 Likes

The warnings are still present in Xcode 15.3 RC2.

Same error for static property 'accent' is still present in Xcode 15.3 Release, build 15E204a.

Reported as Apple Feedback FB13676317

1 Like

Have you tried extension DeveloperToolsSupport.ColorResource: @unchecked Sendable {}? You may just be able to fake the system until it stops complaining. It should fine, hopefully these are simple value types.

2 Likes

Yes, this works as a temporary solution :+1:

Can confirm, that works as a band-aid until Apple fix properly. Thanks.

Xcode 15.4b1 claims to fix this issue (and a similar issue with XCTestCase.fulfillment(of:)).

1 Like

Confirmed