/*
 |  _   ____   ____   _
 | | |‾|  ⚈ |-| ⚈  |‾| |
 | | |  ‾‾‾‾| |‾‾‾‾  | |
 |  ‾        ‾        ‾
 */

import Foundation

public protocol Nameable { }

public extension Nameable {
    
    public static var name: String {
        return String(describing: Self.self)
    }
    
    public func addAccessibilityIdentifiers() {
        for (label, object) in Mirror(reflecting: self).children {
            guard let label = label else { continue }
            let accessibleObject: UIAccessibilityIdentification
            if let view = object as? UIView {
                accessibleObject = view
            } else if let barItem = object as? UIBarItem {
                accessibleObject = barItem
            } else {
                continue
            }
            accessibleObject.accessibilityIdentifier = Self.name + "." + label
        }
    }

}

/*
 |  _   ____   ____   _
 | | |‾|  ⚈ |-| ⚈  |‾| |
 | | |  ‾‾‾‾| |‾‾‾‾  | |
 |  ‾        ‾        ‾
 */

import Foundation

public protocol Nameable { }

public extension Nameable {
    
    public static var name: String {
        return String(describing: Self.self)
    }
    
}

--- 
+++ 
@@ -15,4 +15,19 @@
         return String(describing: Self.self)
     }
     
+    public func addAccessibilityIdentifiers() {
+        for (label, object) in Mirror(reflecting: self).children {
+            guard let label = label else { continue }
+            let accessibleObject: UIAccessibilityIdentification
+            if let view = object as? UIView {
+                accessibleObject = view
+            } else if let barItem = object as? UIBarItem {
+                accessibleObject = barItem
+            } else {
+                continue
+            }
+            accessibleObject.accessibilityIdentifier = Self.name + "." + label
+        }
+    }
+
 }
Add function to apply accessibility identifiers

Uses the property name of all relevant properties on the object. When used with a view controller, this will apply to its stored properties.
