Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feat]: Use devicectl command to handle files for real devices as an option #19166

Closed
KazuCocoa opened this issue Sep 17, 2023 · 14 comments
Closed
Labels
Enhancement feature XCUITest regarding xcuitest driver

Comments

@KazuCocoa
Copy link
Member

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Xcode 15 introduces xcrun devicectl to manage devices. We could use them in some cases. So far, I see overhead than appium-ios-device while considering iOS 17+, probably we could use the devicectl in some places instead of implementing appium-ios-device for ios 17+, it may help our future maintenance.

Then, maybe file management could help:

xcrun devicectl device info files
xcrun devicectl device copy

Describe the solution you'd like
A clear and concise description of what you want to happen.

Current existing implementation

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

@KazuCocoa KazuCocoa added Enhancement feature XCUITest regarding xcuitest driver labels Sep 17, 2023
@mykola-mokhnach
Copy link
Collaborator

It would probably make sense to add a custom devicectl wrapper like with did for simctl (e.g. node-simctl)

@KazuCocoa
Copy link
Member Author

Yes, agree with that

@KazuCocoa
Copy link
Member Author

KazuCocoa commented Sep 17, 2023

Found that the devicectl command did not identify an iOS 16 device on my local. the command raised:

ERROR: The specified device was not found. (com.apple.dt.CoreDeviceError error 1000.)

@KazuCocoa
Copy link
Member Author

Noticed that maybe no methods to "delete" files from a device via xcrun devicectl device right now...?

@KazuCocoa
Copy link
Member Author

We cannot "delete" a file, but can override with zero size file with:

% xcrun devicectl device copy to --device=00008020-000E5CDA0A23002E --domain-type=appDataContainer --user mobile --domain-identifier=com.apple.testmanagerd --source 08B61FA8-80CC-47F1-A214-64988F827E7A --destination Attachments/08B61FA8-80CC-47F1-A214-64988F827E7A
01:12:02  Acquired tunnel connection to device.
01:12:02  Enabling developer disk image services.
01:12:02  Acquired usage assertion.
File Path on Device
/private/var/mobile/Containers/Data/InternalDaemon/F55E307B-2720-4D1D-8F81-79DBF2AC50E1/Attachments/08B61FA8-80CC-47F1-A214-64988F827E7A

Then, 08B61FA8-80CC-47F1-A214-64988F827E7A on the device can be replaced with 08B61FA8-80CC-47F1-A214-64988F827E7A on the host machine. It might be help to prevent making size big, but not sure how we can actually delete them

@mykola-mokhnach
Copy link
Collaborator

We cannot "delete" a file, but can override with zero size file with:

% xcrun devicectl device copy to --device=00008020-000E5CDA0A23002E --domain-type=appDataContainer --user mobile --domain-identifier=com.apple.testmanagerd --source 08B61FA8-80CC-47F1-A214-64988F827E7A --destination Attachments/08B61FA8-80CC-47F1-A214-64988F827E7A
01:12:02  Acquired tunnel connection to device.
01:12:02  Enabling developer disk image services.
01:12:02  Acquired usage assertion.
File Path on Device
/private/var/mobile/Containers/Data/InternalDaemon/F55E307B-2720-4D1D-8F81-79DBF2AC50E1/Attachments/08B61FA8-80CC-47F1-A214-64988F827E7A

Then, 08B61FA8-80CC-47F1-A214-64988F827E7A on the device can be replaced with 08B61FA8-80CC-47F1-A214-64988F827E7A on the host machine. It might be help to prevent making size big, but not sure how we can actually delete them

I had the same idea. It might be a good workaround for now

@KazuCocoa
Copy link
Member Author

KazuCocoa commented Mar 5, 2024

another note. an emopty dir cannot override existing dir.

% xcrun devicectl device copy to --device=00008020-000E5CDA0A23002E --domain-type=appDataContainer --user mobile --domain-identifier=com.apple.testmanagerd --source "empty" --destination Attachments
01:23:28  Acquired tunnel connection to device.
01:23:28  Enabling developer disk image services.
01:23:28  Acquired usage assertion.
ERROR: The specified file could not be transferred. (com.apple.dt.CoreDeviceError error 7000.)
         NSURL = file:///Users/kazu/tmp/videos/empty
--------------------------------------------------------------------------------
ERROR: I/O Error: Could not remove existing file at path Attachments: Operation not permitted (com.apple.dt.remoteservices.error error 11001.)

These also actually did nothing.

% xcrun devicectl device copy to --device=00008020-000E5CDA0A23002E --domain-type=appDataContainer --user mobile --domain-identifier=com.apple.testmanagerd --source "empty-dir" --destination Attachments
01:24:43  Acquired tunnel connection to device.
01:24:43  Enabling developer disk image services.
01:24:43  Acquired usage assertion.
File Path on Device
/private/var/mobile/Containers/Data/InternalDaemon/F55E307B-2720-4D1D-8F81-79DBF2AC50E1/Attachments

% xcrun devicectl device copy to --device=00008020-000E5CDA0A23002E --domain-type=appDataContainer --user mobile --domain-identifier=com.apple.testmanagerd --source "empty-dir" --destination ./
01:25:14  Acquired tunnel connection to device.
01:25:14  Enabling developer disk image services.
01:25:14  Acquired usage assertion.
File Path on Device
/private/var/mobile/Containers/Data/InternalDaemon/F55E307B-2720-4D1D-8F81-79DBF2AC50E1/.
% xcrun devicectl device info files --device=00008020-000E5CDA0A23002E --domain-type=appDataContainer --username mobile --domain-identifier=com.apple.testmanagerd
01:28:06  Enabling developer disk image services.
01:28:06  Acquired usage assertion.
9 files:
Name
------------------------------------------------------------
.com.apple.mobile_container_manager.metadata.plist
Attachments/08B61FA8-80CC-47F1-A214-64988F827E7A
Attachments/0C177732-2609-4117-B464-AE77D9E1B0BE
Attachments/206E98E8-0898-4EF5-8228-E369F6521808

@mykola-mokhnach
Copy link
Collaborator

mykola-mokhnach commented Mar 5, 2024

It is also possible to set attachment lifetime. I assume one of possible values there must be set to delete attachments as soon as the test competes/WDA is killed

@KazuCocoa
Copy link
Member Author

oh, it would be nice if can

@mykola-mokhnach
Copy link
Collaborator

I will add some methods that allow to set lifetime today, so you could try that

@mykola-mokhnach
Copy link
Collaborator

We do use devicectl, so the feature could be closed as resolved

@IshanG97
Copy link

Does anyone know how to load a url on safari on a real connected iPhone? I've tried things like xcrun devicectl device process launch --device <device-udid> com.apple.mobilesafari --payload-url http://www.google.com but no luck

@KazuCocoa
Copy link
Member Author

We do it via WDA/remote debugger. Perhaps I tried the method but did not work.
https://github.com/appium/appium-xcuitest-driver/blob/f00d231d6ab0986de7c6d5fa090ec4f9f283dc80/lib/commands/general.js#L158-L174

@IshanG97
Copy link

IshanG97 commented May 16, 2024

So i tried xcrun devicectl device process launch --device <device-udid> --payload-url http://www.google.com com.apple.mobilesafari and it works - note i put the args before the app bundleId

FYI it also works with com.google.chrome.ios, but i haven't tried other web browsers yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement feature XCUITest regarding xcuitest driver
Projects
None yet
Development

No branches or pull requests

3 participants