MobiVM / robovm

Ahead of time compiler for JVM bytecode targetting iOS, Mac OSX and Linux
https://mobivm.github.io
967 stars 133 forks source link

Missing Bindings for UIAccessibilityTraits. #735

Open sinceredevotion opened 1 year ago

sinceredevotion commented 1 year ago

Issue details

When setting traits of a UIAccessibilityElement, this is the error that I get:

Error: class java.lang.UnsatisfiedLinkError, Optional @GlobalValue method org/robovm/apple/uikit/UIAccessibilityTraits.NoneValue()J not bound

Reproduction steps/code

Here is a snippet of code:

UIAccessibilityElement accessibilityElement = new UIAccessibilityElement(iosAccessibility);

    accessibilityElement.setAccessibilityFrame(new CGRect(x, y, width, height));

    if (item.GetName() != null)
        accessibilityElement.setAccessibilityLabel(item.GetName());
    else
        accessibilityElement.setAccessibilityLabel("Default Name");

    if (item.GetDescription() != null)
        accessibilityElement.setAccessibilityHint(item.GetDescription());
    else
        accessibilityElement.setAccessibilityHint("Default Description");

    if (item.GetAccessibilityCode() == item.Get_Libraries_Interface_Item__NOT_ACCESSIBLE_())
        accessibilityElement.setAccessibilityElement(false);
    else
        accessibilityElement.setAccessibilityElement(true);

    UIAccessibilityTraits traits = UIAccessibilityTraits.AllowsDirectInteraction; // The line that is crashing
    accessibilityElement.setAccessibilityTraits(traits);

    // Add the accessibility element to the list
    accessibilityElements.add(accessibilityElement);

    // Inform iOS that the accessibility elements have changed
    UIAccessibilityGlobals.postNotification(UIAccessibilityNotification.LayoutChangedNotification, accessibilityElement);

Configuration

2.3.19

Build Tools:

Versions:

Please provide the version of RoboVM, XCode and JDK used

Build Targets: iPhone 14 Pro Max iOS 16.

Stacktrace

//Please provide the stacktrace if applicable 

Error: class java.lang.UnsatisfiedLinkError, Optional @GlobalValue method org/robovm/apple/uikit/UIAccessibilityTraits.NoneValue()J not bound
   file: IOSAccessibility.java,  class: plugins.quorum.Libraries.Interface.Accessibility.IOSAccessibility,  action: Add,  line: 154 
   file: IOSAccessibility.quorum,  class: Libraries.Interface.Accessibility.IOSAccessibility,  action: Add,  line: -1 
   file: Layer2D.quorum,  class: Libraries.Game.Layer2D,  action: Add,  line: 249 
   file: Game.quorum,  class: Libraries.Game.Game,  action: Add,  line: 615 
   file: Main.quorum,  class: ChartTest2,  action: Add,  line: -1 
   file: Main.quorum,  class: ChartTest2,  action: CreateGame,  line: 31 
...
dkimitsa commented 1 year ago

hi, thanks for reporting there is a bug in bindings, will be fixed during ios17 binding update (don't close this issue). meanwhile please use folloiwing workaround. call this line somewhere before accessing UIAccessibilityTraits

ObjCRuntime.bind(UIAccessibilityTraits.class);
dkimitsa commented 1 year ago

fixed with https://github.com/MobiVM/robovm/pull/758/commits/83b02822ec43c62e970e907812494e30c03c1470