electricbubble / gidevice

communicate with iOS devices implemented with Golang
MIT License
274 stars 68 forks source link

gidevice 和 gwda 如何在一个项目里配合使用呢? #14

Closed aichy126 closed 2 years ago

aichy126 commented 2 years ago

gidevice 开启 XCTest 确认连接状态使用 gwda控制

    out, cancel, err := ID.XCTest(bundleID)
    if err != nil {
        log.Fatal(err)
    }

    done := make(chan os.Signal, 1)
    signal.Notify(done, os.Interrupt)

    go func() {
        for s := range out {
            fmt.Print(s)
            has := strings.Contains(s, "Using singleton test manager")
            if has {
                driver, _ := gwda.NewUSBDriver(nil)
                driver.PressButton(gwda.DeviceButtonHome)
                driver.SiriActivate("What's the weather like today")
            }
        }
    }()

    <-done
    cancel()

或者有更好的办法么?

electricbubble commented 2 years ago

我更建议给 gwda 单启一个协程,

用 chan 去通知 gwda 执行

aichy126 commented 2 years ago

好的感谢