I need to access data from webkit applications such as Safari, Mail and maybe others. I can see in the Accessibility Inspector
there is :AXTextMarker
Accessibility apps need to be added in System Preferences in the following section:
System Preferences -> Security & Privacy -> Privacy tab -> Accessibility (on the left)
Note that during development you need to include Xcode in this list if you are developing/running within Xcode.
I didn't test out your exact code, but I tested some comparable swift code and that worked fine provided Xcode was added in that spot in system preferences.