Comments (14)
Seems you need to load UIAccessibility.framework.
(lldb) image lookup -vn _accessibilityTreeAsString
1 match found in /Users/mrhappyasthma/Library/Developer/Xcode/iOS DeviceSupport/12.1 (16B92)/Symbols/System/Library/PrivateFrameworks/UIAccessibility.framework
from happydebugging.
So the private APIs do require UIAccessibility.framework, however it's a private framework so there's no way (that I can find) to force this to load via lldb
nor using an NSBundle
with a fixed path.
However the framework is loaded whenever VoiceOver is enabled. (And stays loaded even if voiceover is disabled in a given session).
from happydebugging.
Actually, at least when building to device, it appears we can use:
NSBundle *bundle = [NSBundle bundleWithPath:@"/System/Library/PrivateFrameworks/UIAccessibility.framework"];
BOOL success = [bundle load];
This passes and works when building to device. Will test the simulator next. I imagine it will fail, but we'll see.
from happydebugging.
Confirmed it doesn't work on simulator. This will make writing tests very difficult, so I'll probably just do manual testing for these.
from happydebugging.
// Precheck for the library.
for (NSBundle *bundle in [NSBundle allFrameworks]) {
if ([[bundle resourcePath] isEqual:@"/System/Library/PrivateFrameworks/UIAccessibility.framework"]) {
return;
}
}
// Load the framework.
NSBundle *b = [NSBundle bundleWithPath:@"/System/Library/PrivateFrameworks/UIAccessibility.framework"];
BOOL success = [b load];
NSLog(@"success = %ld", (long)success);
}
from happydebugging.
Added a command for accessibilityTree
in 47378f5. This is more of a proof-of-concept than anything. This can be forked to implement similar checks to add the other accessibility methods.
I'm limited to testing on simulator locally, so I will have to test on device later.
from happydebugging.
Some other potential ones:
- (bool)_accessibilityHasVisibleFrame;
- (id)_accessibilityIndexPath;
- (id)_accessibilityParentView;
- (id)_accessibilityResponderChainForKeyWindow;
- (id)_accessibilitySortedElementsWithin;
- (id)_accessibilityVisibleElements;
- (id)_axDebugTraits;
- (id)_axElementsDescription;
from happydebugging.
For _accessibilityLeftDescendentsWithCount:options:
I see:
(lldb) po $arg4
<UIAccessibilityElementTraversalOptions: 0x282f198f0> - next, has predicate
(lldb) ivars 0x282f198f0
<__NSArrayM 0x282f19b30>(
(bool) _shouldReturnScannerGroups,
(bool) _shouldOnlyIncludeElementsWithVisibleFrame,
(bool) _shouldIncludeKeyboardObscuredElements,
(bool) _shouldUseAllSubviews,
(bool) _includeHiddenViews,
(bool) _includeWindowlessViews,
(bool) _sorted,
(bool) _ignoreObscuresScreen,
(bool) _includeDirectDescendantsOnly,
(bool) _includeAncestorsOfSelfInSiblingMatch,
(bool) _forSpeakScreen,
(bool) _shouldIncludeStatusBarWindow,
(long long) _direction,
(~block~) _leafNodePredicate -> 0x282f18930,
(NSArray *) _allowedViewsForTraversal -> nil
from happydebugging.
from happydebugging.
Some of the traversal logger APIs:
from happydebugging.
The magic sauce seems to be:
po [0x138ff2570 _accessibilityLeafDescendantsWithOptions:[UIAccessibilityElementTraversalOptions defaultVoiceOverOptions]]
from happydebugging.
[UIAccessibilityElementTraversalOptions defaultVoiceOverOptions]
Has the following properties:
BOOL shouldIncludeStatusBarWindow => NO
BOOL forSpeakScreen => NO
BOOL includeAncestorsOfSelfInSiblingMatch => NO
BOOL includeDirectDescendantsOnly => NO
BOOL ignoreObscuresScreen => NO
BOOL sorted => YES
BOOL includeHiddenViews => NO
BOOL shouldUseAllSubviews => NO
BOOL shouldIncludeKeyboardObscuredElements => NO
BOOL shouldOnlyIncludeElementsWithVisibleFrame =>NO
BOOL shouldReturnScannerGroups => NO
from happydebugging.
Useful look into the private h eaders: https://github.com/w0lfschild/macOS_headers/tree/master/macOS/PrivateFrameworks/UIAccessibility/1.0
from happydebugging.
One thing I noticed is that the a11y commands tend to not print the full tree of data until AFTER I poke around on the app with the a11y inspector. Then anytime in the future it seems to print the right values.
There must be some other type of set up happening between the inspector and the app process that I'm not yet doing.
from happydebugging.
Related Issues (18)
- Error when using `ivars` command. HOT 3
- Recursively print superclass ivars for `ivars` commands.
- Allow `ivars` command to take Class objects (or strings with class names?)
- Add new command to implement `setFrame:` override on a UIView at runtime. HOT 5
- Add a command to fake a low memory warning (even on device).
- Add a command to highlight a given element on screen.
- [Bug] pcolor truncates floats to ints
- Add command for UIView -isHiddenOrHasHiddenAncestor
- Update python scripts to be fully python3 compliant.
- Screenshot command fails in modern Xcode HOT 1
- Update the `result.Print()` statements to include a newline. HOT 1
- Add a command to list all commands via the LLDB command interface. HOT 2
- Error in `pframe` command. HOT 2
- [Request] Add comment to print UIColor as hex code + easy to read RGBA values. HOT 1
- Add tests for `screenshot` and `png` command.
- Screenshot command fails on device
- Print out values for primitives in `ivars` command. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from happydebugging.