Skip to content

Conversation

@simlay
Copy link
Collaborator

@simlay simlay commented Dec 31, 2025

I've been playing around with the objc2-xc-ui-automation crate and figure some additional features should be added.

Most of this is really just a stop gap in place of #408

I spent like 20 minutes fighting Retained<XCUIElementQuery> and &XCUIElementQuery and then I asked claude for some help which it suggested dereferencing *mut T. I'm not really a fan but I'm not sure what's better.

I was already in the space and had noticed some other pieces that would be nice.

  • framework-crates/objc2-xu-ui-automation/src/device_buttons.rs has the XCUIDeviceButtons conditionally compiled for iOS, watchOS, visionOS and tvOS. These can be used via pressButton.
  • framework-crates/objc2-xu-ui-automation/src/siri.rs adds getting the siriService out of the XCUIDevice, and the corresponding XCUISiriService struct and it's few calls.
  • framework-crates/objc2-xu-ui-automation/src/orientation.rs adds the calls of setOrientation and orientation on XCUIDevice. This should ideally be behind a feature flag of objc2-ui-kit as the generated stuff would be and then have objc2-ui-kit as an optional dependency. It's sloppy but I figure that just duplicating the UIOrientation struct might be the least bad. Is there a flag to translation-config.toml to do this nicely?

If there's not a great way to do the Index trait or orientation, I'm cool with dropping them.

@simlay simlay changed the title impl Index on XCUIElementQuery in objc2-xc-ui-automation impl Index on XCUIElementQuery, siri, device buttons and orientation in objc2-xc-ui-automation Dec 31, 2025
@simlay simlay marked this pull request as ready for review December 31, 2025 04:01
@madsmtm madsmtm added enhancement New feature or request A-framework Affects the framework crates and the translator for them labels Dec 31, 2025
@madsmtm madsmtm added this to the frameworks v0.4.0 milestone Dec 31, 2025
Copy link
Owner

@madsmtm madsmtm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with carrying manual additions like these until we progress further on #408.

@simlay
Copy link
Collaborator Author

simlay commented Dec 31, 2025

I tested XCUIDevice::setOrientation, XCUIDevice::pressButton(XCUIDeviceButton::Home) and XCUISiriService::activateWithVoiceRecognitionText(&NSString::from_str("What is the capital of germany?"));. This is the recording:

record-compressed.mp4

The change in orientation doesn't change the macOS simulator app's orientation but it does actually change the orientation of the app inside the simulator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-framework Affects the framework crates and the translator for them enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants