How to to expose elements for automation but not for accessibility in swift UIKit?

I have two views in a container view as below

@IBOutlet weak var dataDisclosureView: UIStackView! // Main ContainerView

@IBOutlet private weak var titleLabel: UILabel! {
        didSet {
            titleLabel.text = "Hello"
        }
    }
        
    @IBOutlet private weak var descriptionLabel: UILabel! {
        didSet {
            descriptionLabel.text = "World"
        }
    }
    
    @IBOutlet weak var descriptionView: UIStackView! { // sub container view containing titleLabel and descriptionLabel
        didSet {
            descriptionView.isAccessibilityElement = true
            descriptionView.accessibilityLabel = "Hello"
            descriptionView.accessibilityIdentifier = "test_hello"

        }
    }
    
    @IBOutlet private weak var requestButton: UIButton! {
        didSet {
            requestButton.isAccessibilityElement = true
            requestButton.accessibilityLabel = "Request Button"
            requestButton.accessibilityIdentifier = "test_button"
        }
    }

override func viewDidLoad() {
        super.viewDidLoad()
        dataDisclosureView.isAccessibilityElement = false
        dataDisclosureView.accessibilityElements = [ descriptionView ?? "" ]
        if #available(iOS 17.0, *) {
            dataDisclosureView.automationElements = [ descriptionView ?? "",
                                                      requestButton ?? ""]
        } else {
            // Fallback on earlier versions
        }
       let requestButtonAction = UIAccessibilityCustomAction(name: "start",
                                                          target: self,
                                                          selector: #selector( request))
    dataDisclosureView.accessibilityCustomActions = [ requestButtonAction ]
    }

My issue is I want AccessibilityIdentifers for descriptionLabel, titleLabel, requestButton and hintLabel(For Automation) and accessibility labels for descriptionView and requestButton (VoiceOver Accessibility).

But I am unable to see accessibilityIdentifier for Button, TitleLabel and descriptionLabel in AccessibilityInspector. what am I doing wrong here?

PS: I also followed below video :

https://www.youtube.com/watch?v=IAqzXI3kFCk

This is a working solution

 dataDisclosureView.accessibilityElements = [dataDisclosureView as Any,
                                           titleLabel as Any,
                                           descriptionLabel as Any,
                                           requestButton as Any,
                                           hintLabel as Any]
        if #available(iOS 17.0, *) {
            dataDisclosureView.automationElements =  [titleLabel as Any,
                                             descriptionLabel as Any,
                                             requestButton as Any,
                                             hintLabel as Any]
        } else {
            // Fallback on earlier versions
        }

but I am not satisfied with that because in one of Apple WWDC video it was mentioned that if we want exempt item from voice over accessibility don’t add it in accessibilityItems and if we want in automation elements just add it. They haven’t provided deeper details . Reference is https://www.youtube.com/watch?v=IAqzXI3kFCk also adding screenshot about what I am saying

According to this it should be

dataDisclosureView.accessibilityElements = [dataDisclosureView as Any,
                                           titleLabel as Any,
                                           descriptionLabel as Any,
                                           requestButton as Any]
        if #available(iOS 17.0, *) {
            dataDisclosureView.automationElements =  [titleLabel as Any,
                                             descriptionLabel as Any,
                                             requestButton as Any,
                                             hintLabel as Any]
        } else {
            // Fallback on earlier versions
        }

Recognized by Mobile Development Collective

1

You’ve made dataDisclosureView invisible to VoiceOver by setting isAccessibilityElement = false. When isAccessibilityElement is set to false on a container view, it prevents the container itself from being read by VoiceOver. However, this can also limit the visibility of its subviews in Accessibility Inspector, depending on how accessibilityElements is configured.

Ensure Subviews Are Individually Accessible:

To make each subview accessible, you can iterate through them and set isAccessibilityElement = true:

dataDisclosureView.subviews.forEach { $0.isAccessibilityElement = true }

This will allow titleLabel, descriptionLabel, and requestButton to be individually accessible and show up in Accessibility Inspector.

Configure accessibilityElements for Custom Order:

Since you’ve set dataDisclosureView.accessibilityElements = [descriptionView ?? “”], only descriptionView is currently accessible to VoiceOver. If you need additional elements to be read (like titleLabel, descriptionLabel, and requestButton), include them in the accessibilityElements array in the order you want them read:

dataDisclosureView.accessibilityElements = [descriptionView as Any, requestButton as Any]

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật