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

Can't use 'ios image *' cli commands as intended #58

Closed
shamanec opened this issue Aug 23, 2021 · 11 comments · Fixed by #61
Closed

Can't use 'ios image *' cli commands as intended #58

shamanec opened this issue Aug 23, 2021 · 11 comments · Fixed by #61

Comments

@shamanec
Copy link
Sponsor Collaborator

shamanec commented Aug 23, 2021

If I have an image already mounted on the device and I execute 'ios image list' I get a proper looking response like this:
{"level":"info","msg":"2f44230545372e7e64bdd6f19ee7c37154d1ea1359bb84db4b0ad1220137cfe5e8021dac74faf5f6163ab1bfb7705da56b5046cb6ae12a041f10c3c0e9175348d4551f05b48c255ad25ba1bfd0fee8d6f07f71389a6139f5341b2bae7c4e39bc57b0be6a721550ef8fcde7711bb64e6b523f839cd3df741272cb135ec986712e","time":"2021-08-23T10:20:59+03:00"}
If I have an image already mounted on the device and I try to mount another I also get a proper looking response like this:
{"level":"fatal","msg":"there is already a developer image mounted, reboot the device if you want to remove it. aborting.","time":"2021-08-23T10:21:24+03:00"}
BUT
if I don't have an image already mounted on the device and I try executing either 'ios image list', 'ios image mount' or 'ios image auto' I always get the same error:
{"err":"invalid response: \u003cnil\u003e","level":"fatal","msg":"failed getting image list","time":"2021-08-23T10:23:33+03:00"}
The issue occurs regardless if I pair the device beforehand or not
Tested on Ubuntu 18.04.5 LTS

@danielpaulus
Copy link
Owner

Interestimg, which device and which ios version is that?

@shamanec
Copy link
Sponsor Collaborator Author

iPhone SE, iOS 13.5.1, Ubuntu 18.04.5 LTS

@danielpaulus
Copy link
Owner

I can actually reproduce it on my iphone 5s with iOS 12, should be an easy fix but I see you sent a PR already

@danielpaulus
Copy link
Owner

danielpaulus commented Aug 25, 2021

The issue is actually here:

You can see that I am getting a dictionary or map[string] interface{} as response from the device

signatures, ok := resp["ImageSignature"]
	if !ok {
		return nil, fmt.Errorf("invalid response: %+v", signatures)
	}

and I am expecting it to contain an ImageSignature array.
For iOS 14 and above this seems to work. Apparently in earlier versions of iOS that dictionary did not exist in the response and you just get an empty response back.
If you can set a breakpoint at line 60 and try with two different iOS devices, one on iOS 14+ and one with iOS 12/13 you will see what I mean.

For a fix, I would grab the version of the device first and then modify the code to treat devices depending on their version.

@shamanec
Copy link
Sponsor Collaborator Author

:D I wish I knew how to debug this project but I'll check how it happens :P But what you are saying makes sense, you can reject my PR, unfortunately I have only device available so I can't do very comprehensive testing :( Can you explain to me why it returns proper response when there are images but empty response when there are none? What exactly is missing in the case without images?

@danielpaulus
Copy link
Owner

What IDE are you using?
You should really attend my Appium talk next month :-D I will talk a bit about how to use dproxy.
Ah ok if you have only one device than this will be hard to test. Luckily I kept a few old iPhones my wife had years ago around and have a new iPhone 12.

Both responses are proper, it is just that Apple changes their interfaces now and then.
For iOS 13 and below if you send the LookupImage request, you receive an empty dictionary.
For iOS 14+ you receive a dictionary that contains one key "ImageSignature" containing an array with signatures that will be empty if no images are installed.

I usually write my code in a fail fast manner to prevent inexplicable or unpredictable behavior, so if anything unexpected happens it immediately fails. That makes it easier to quickly find errors and fix them properly.

@shamanec
Copy link
Sponsor Collaborator Author

I am using Visual Studio Code but I don't actually run the project through it, I just use 'go build' to make the executable and test with it ( this is as far as my current Go knowledge goes :D ) I am inclined to try and contribute to the project but it will probably take me months to understand everything and do something on my own :) Maybe I should just go and find one more second hand device to test on at least 14+. Thank you for the comprehensive answer! About the Appium talk - how can I attend it?

@danielpaulus
Copy link
Owner

I'll be at Appium Conf https://appiumconf.com/
but since you are a sponsor we can also have a zoom chat or sth.
Happy to explain a little more on how this actually works.

I can write a quick fix for the image mounting issue btw. This will take like 5 minutes so I can do it later today after work.

@shamanec
Copy link
Sponsor Collaborator Author

Fixing this will be great, I can keep working without updating my iPhone yet :D I'll do my best to attend the conf, wasn't actually aware it is happening so thanks for the notice. If you are willing to explain a little more that will be great but please only on your own accord, since using up your time because I give you 10$ makes me feel bad :D

@danielpaulus
Copy link
Owner

Haha no worries. It's a hobby project so I enjoy spending some extra time :-D

@shamanec
Copy link
Sponsor Collaborator Author

Seems to work as expected - thanks a bunch!

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 a pull request may close this issue.

2 participants