Skip to content

feat: add physical devices support#122

Merged
okwasniewski merged 28 commits intookwasniewski:mainfrom
itsramiel:feat/add-physical-devices-support
Sep 7, 2024
Merged

feat: add physical devices support#122
okwasniewski merged 28 commits intookwasniewski:mainfrom
itsramiel:feat/add-physical-devices-support

Conversation

@itsramiel
Copy link
Contributor

@itsramiel itsramiel commented Aug 27, 2024

Summary:

Display physical iOS and Android devices

closes #121
The idea here to be able to view connected devices.

For iOS, devices are visible even if not connected via cable. The system also marks the device as offline if the device is not connected to the internet and not connected by cable, otherwise it is marked as online. The booted property for iOS physical devices is determined according whether the device is online or not.

For android, connected devices are figured out using adb devices -l

Applescript commands are adjusted to account for the changes.
Link to raycast extension pr

Motivation

For iOS, this allows you to copy your uuid which can be useful at times or you create a custom command.
For android, you can paste to clipboard(main reason I worked on this pr), launch logcat, and also custom commands.

Other changes

I hide sections that do not include any devices which wasnt the case previously. Assuming you are ios dev only that work only with simulators, you would see 3 other empty sections, which I personally think is not nice but that is just my opinion

Changelog:

feat: display physical ios and android devices
feat: hide sections that include no devices

Test Plan:

Android

Screen.Recording.2024-08-28.at.7.mp4

iOS(didnt record video cause would like to keep the uuid private 🤓):
image

@itsramiel itsramiel marked this pull request as ready for review August 28, 2024 18:09
@itsramiel
Copy link
Contributor Author

@okwasniewski I believe it is ready

@okwasniewski okwasniewski self-requested a review August 29, 2024 08:00
@okwasniewski
Copy link
Owner

Hey @itsramiel,

Thanks for this PR!

I'm going to review and test it over the weekend 🙌

Copy link
Owner

@okwasniewski okwasniewski left a comment

Choose a reason for hiding this comment

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

Overall looks good!

I did a first code pass, going to test it more over the weekend

@okwasniewski
Copy link
Owner

I've compiled the app and for some reason I can see my macbook there:

Here is the output of xctrace list devices

❯ xctrace list devices
== Devices ==
MacBook Pro (Oskar) (123)
iPhone (Oskar) (17.6.1) (123)

== Devices Offline ==
Apple Vision Pro (2.0) (123)
Screenshot 2024-08-31 at 14 48 15

It would be nice to support the naming convention of iPhone (Name) as this is the default naming in my country and probably others too.

@okwasniewski
Copy link
Owner

Also I found this: xcrun devicectl list devices which shows the output for listing only devices. Maybe faster (as it doesn't list simulators)

@okwasniewski
Copy link
Owner

Looks like Android Devices are working smoothly!

Screenshot 2024-08-31 at 16 38 38

@itsramiel
Copy link
Contributor Author

I've compiled the app and for some reason I can see my macbook there:

Here is the output of xctrace list devices

❯ xctrace list devices
== Devices ==
MacBook Pro (Oskar) (123)
iPhone (Oskar) (17.6.1) (123)

== Devices Offline ==
Apple Vision Pro (2.0) (123)
Screenshot 2024-08-31 at 14 48 15

It would be nice to support the naming convention of iPhone (Name) as this is the default naming in my country and probably others too.

Would be great if we can setup a unit test for parsing results, so you know nothing breaks when fixing for other cases. I am not familiar with swift unit testing but that's an idea

@itsramiel
Copy link
Contributor Author

itsramiel commented Aug 31, 2024

Also I found this: xcrun devicectl list devices which shows the output for listing only devices. Maybe faster (as it doesn't list simulators)

That is a pretty good command that I didnt know about. One issue I see is that it doesnt provide the ios version 🙃.

EDIT:
So while the command doesnt provide os version directly, we can get more information by querying each device:
xcrun devicectl device info details --device <uuid>

This provies way more info though that maybe could be useful? Try it out with your device.

You can know if user is connected by usb or not, connected(tunnel state) and way more

EDIT 2:

For the future you can also interact with ios devices? Wow seems like more ideas for features
image

@okwasniewski
Copy link
Owner

Would be great if we can setup a unit test for parsing results, so you know nothing breaks when fixing for other cases. I am not familiar with swift unit testing but that's an idea

Yeah, this is great idea. I can write tests for current implementation in separate PR and then you can add it for real devices

@okwasniewski
Copy link
Owner

I also learned about devicectl today, really handy and definitely bunch of cool stuff to implement in upcoming PRs!

I also noticed that you can pass -j flag and specify json file to output the results. On the other hand not having version near the device is not such a big issue because you can't change the version anyways.

For simulators is much more useful because you can change their versions.

@okwasniewski
Copy link
Owner

@itsramiel Just checked and it looks like Xcode 15 introduced devicectl in that case let's stay with your current approach. We can add features that use devicectl in upcoming PRs and check if user has Xcode 15 but let's add real device listing for everyone.

Im going to write tests for parsers today.

@itsramiel
Copy link
Contributor Author

itsramiel commented Sep 1, 2024

@itsramiel Just checked and it looks like Xcode 15 introduced devicectl in that case let's stay with your current approach. We can add features that use devicectl in upcoming PRs and check if user has Xcode 15 but let's add real device listing for everyone.

Im going to write tests for parsers today.

I just pushed the devicectl changes 😅

EDIT: do I revert it?

@okwasniewski
Copy link
Owner

@itsramiel Ugh, sorry.. okay i guess let's make this feature available only for Xcode >= 15.

We will need to make sure that it doesn't break on older Xcode versions (if xcrun devicectl doesn't exist lets just don't display the iOS Devices section)

@okwasniewski
Copy link
Owner

I've extracted DeviceParser to another class and wrote some tests here: #125

Copy link
Owner

@okwasniewski okwasniewski left a comment

Choose a reason for hiding this comment

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

We are getting there! Some additional cleanups are needed but overall it looks good

@okwasniewski
Copy link
Owner

Thanks for working on this!

@okwasniewski okwasniewski merged commit 7b710d7 into okwasniewski:main Sep 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

New Feature: Display connected devices to allow copying name, udid, or pasting to Android device

2 participants