UIAccessibility.Notification concurrency errors with Xcode 16 beta 2

I am running into some Swift 6 concurrency errors that I think are due to an odd oversight in the UIAccessibility Swift interface.

There are a number of constants defined in here for various things, most of which are marked "let" (appropriately).

However, the constants for notifications in extension UIAccessibility.Notification are all marked as var for some reason. For example:

public static var pageScrolled: UIAccessibility.Notification

Because it is var, not let, anytime I try to access it, I get a concurrency violation. I am baffled as to how I am supposed to work around this.

For example, this line of code:

UIAccessibility.post(notification: .pageScrolled, argument: "test")

gives the error: "Reference to static property 'pageScrolled' is not concurrency-safe because it involves shared mutable state"

I can't for the life of me figure out how to work around this. I guess maybe define my own constant somewhere and suss out the rawValue somehow for now? This really needs to be fixed in the SDK.

Answered by Frameworks Engineer in 793746022

This is indeed a known issue in the SDK as of beta 2 that we are aware of. These declarations will be corrected in the SDK so you won't need to make any changes on your end.

Since the constant is marked as "var", couldn't I also do this if I wanted and just totally break the SDK?

		UIAccessibility.Notification.pageScrolled = UIAccessibility.Notification(rawValue: 12345)

Accepted Answer

This is indeed a known issue in the SDK as of beta 2 that we are aware of. These declarations will be corrected in the SDK so you won't need to make any changes on your end.

Thanks! For now I'm using this just so I can get rid of the errors and move on. I'll back the changes out when your fix lands.

	fileprivate let pageScrolled = UIAccessibility.Notification(rawValue: 1009)
	fileprivate let layoutChanged = UIAccessibility.Notification(rawValue: 1001)

I found more of them in that same file. All the constants in extension UIAccessibilityTraits:

extension UIAccessibilityTraits {

    public static var none: UIAccessibilityTraits

These are all fixed in Xcode 16 beta 3. Thanks!

UIAccessibility.Notification concurrency errors with Xcode 16 beta 2
 
 
Q