You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Unable to connect to HID reply port using FBSimulatorControl framework #525
Using FBSimulatorControl in a CLI to control multiple simulators and I am not able to register HID port
Description
I am launching the device in direct launch mode. I am able to create the simulator. I am creating the HID, and then boot the simulator. But then when I try to connect the HID port, it fails. The error shows the port has not been registered
Reproduction
// Creatind HID
let simHIDFuture = FBSimulatorHID.hid(for: self.sim!)
simHIDFuture.onQueue(.main, notifyOfCompletion: {(simHIDFut) in
})
do {
try simHIDFuture.await()
} catch let simHIDCreateError {
print("[Error]HID creation for simulator \(sim!.udid) failed because \(simHIDCreateError.localizedDescription)")
throw simHIDCreateError
}
self.simHID = simHIDFuture.result!
// Booting simulator in direct launch mode
let bootOptions = FBSimulatorBootOptions.enableDirectLaunch
let bootConfiguration = FBSimulatorBootConfiguration.default.withScale(scale).withOptions(bootOptions)
if sim?.state != .booted {
let simBootFuture = sim?.boot(with: bootConfiguration)
simBootFuture?.onQueue(.main, notifyOfCompletion: { (simBoot) in
})
do {
try simBootFuture?.await()
} catch let bootError {
print("[Error] Failed to boot simulator \(sim!.udid) because \(bootError.localizedDescription)")
throw bootError
}
let _ = simBootFuture?.result
}
// Connecting HID for reply port
let simHIDConnectFuture = simHID!.connect()
simHIDConnectFuture.onQueue(.main, notifyOfCompletion: { (simHIDConnectFuture) in
})
do {
try simHIDConnectFuture.await()
} catch let hidConnectError {
print("[Error] HID reply port failed to connect to simulator \(sim!.udid) because \(hidConnectError.localizedDescription)")
throw hidConnectError
}
let _ = simHIDConnectFuture.result
The console will print [Error] HID reply port failed to connect to simulator 04B6D540-3E5A-4343-AEEE-4DE9B40B56DA because Cannot connect when there is no registration port
Can anyone please let me know what I am missing out?
The HID object can't be created until the Simulator is booted.
If you want to access this, use the connectToHID method on FBSimulator instead, this should ensure that all the invariants are met. For the most part, you'll not need to create instances of most helper classes yourself, they are all exposed on FBSimulator.
Can you make sure that SimulatorKit is loaded by using FBSimulatorControlFrameworkLoader.xcodeFrameworks.loadPrivateFrameworksOrAbort before any of the calls?
I think your code is taking an old code path that might not work on newer versions of xcode.
I have tried in different machines. The result seems to be same. Used FBSimulatorControlFrameworkLoader.xcodeFrameworks.loadPrivateFrameworksOrAbort. The path seems to be fine. Still the HID registration port is connected but the reply port is not getting registered
Activity
lawrencelomax commentedon May 22, 2019
The
HIDobject can't be created until the Simulator is booted.If you want to access this, use the
connectToHIDmethod onFBSimulatorinstead, this should ensure that all the invariants are met. For the most part, you'll not need to create instances of most helper classes yourself, they are all exposed onFBSimulator.aravindgs commentedon May 23, 2019
@lawrencelomax I used the
connectToHIDmethod as suggested. I was able to get theHIDobject. But I was unable to obtain the reply port.The registration port was
14671.It failed to connect to the reply port. It produced an error.
The console log was
[Error] Failed to get the Indigo Reply Port 268451843lawrencelomax commentedon May 30, 2019
Can you make sure that
SimulatorKitis loaded by usingFBSimulatorControlFrameworkLoader.xcodeFrameworks.loadPrivateFrameworksOrAbortbefore any of the calls?I think your code is taking an old code path that might not work on newer versions of xcode.
aravindgs commentedon Jul 12, 2019
I have tried in different machines. The result seems to be same. Used
FBSimulatorControlFrameworkLoader.xcodeFrameworks.loadPrivateFrameworksOrAbort. The path seems to be fine. Still the HID registration port is connected but the reply port is not getting registered