fix: add explicit dev img mounted check for dev ipsw idev cmds

This commit is contained in:
blacktop
2022-10-31 17:44:15 -06:00
parent e0fc146829
commit 595a114707
4 changed files with 34 additions and 1 deletions
+4
View File
@@ -75,6 +75,10 @@ var FetchsymsCmd = &cobra.Command{
ldc.Close()
}
if err := utils.IsDeveloperImageMounted(dev.UniqueDeviceID); err != nil {
return fmt.Errorf("for device %s: %w", dev.UniqueDeviceID, err)
}
cli, err := fetchsymbols.NewClient(dev.UniqueDeviceID)
if err != nil {
return fmt.Errorf("failed to connect to fetchsymbols service: %w", err)
+9
View File
@@ -88,6 +88,11 @@ var ScreenCmd = &cobra.Command{
return err
}
ldc.Close()
if err := utils.IsDeveloperImageMounted(dev.UniqueDeviceID); err != nil {
return fmt.Errorf("for device %s: ensure Developer Mode is enabled on iOS16+ AND %w", dev.UniqueDeviceID, err)
}
return saveScreenshot(dev, output)
} else {
devs, err := utils.PickDevices()
@@ -96,6 +101,10 @@ var ScreenCmd = &cobra.Command{
}
for _, dev := range devs {
if err := utils.IsDeveloperImageMounted(dev.UniqueDeviceID); err != nil {
return fmt.Errorf("for device %s: ensure Developer Mode is enabled on iOS16+ AND %w", dev.UniqueDeviceID, err)
}
if err := saveScreenshot(dev, output); err != nil {
return fmt.Errorf("failed to save screenshot: %w", err)
}
+20
View File
@@ -9,6 +9,7 @@ import (
"github.com/apex/log"
"github.com/blacktop/ipsw/pkg/usb"
"github.com/blacktop/ipsw/pkg/usb/lockdownd"
"github.com/blacktop/ipsw/pkg/usb/mount"
)
func PickDevice() (*lockdownd.DeviceValues, error) {
@@ -131,3 +132,22 @@ func PickDevices() ([]*lockdownd.DeviceValues, error) {
return picked, nil
}
}
func IsDeveloperImageMounted(udid string) error {
cli, err := mount.NewClient(udid)
if err != nil {
return fmt.Errorf("failed to connect to mobile_image_mounter: %w", err)
}
defer cli.Close()
images, err := cli.ListImages(mount.ImageTypeDeveloper)
if err != nil {
return fmt.Errorf("failed to list images: %w", err)
}
if len(images) == 0 {
return fmt.Errorf("mount the Developer image with the `ipsw idev img mount` command or by opening Xcode")
}
return nil
}
+1 -1
View File
@@ -30,7 +30,7 @@ type Client struct {
func NewClient(udid string) (*Client, error) {
c, err := lockdownd.NewClientForService(serviceName, udid, false)
if err != nil {
return nil, fmt.Errorf("you might need to enable Developer Mode in your device Settings app OR mount the Developer image with `ipsw idev img mount`: %v", err)
return nil, fmt.Errorf("you might need to enable Developer Mode in your device Settings app: %v", err)
}
return &Client{
c: c,