This code crashes on the virtualController.connect():
let virtualConfiguration = GCVirtualControllerConfiguration()
virtualConfiguration.elements = [GCInputLeftThumbstick,
GCInputButtonA, GCInputButtonB]
let virtualController = GCVirtualController(configuration: virtualConfiguration)
// Connect to the virtual controller if no physical controllers are available.
if GCController.controllers().isEmpty {
virtualController.connect()
}
This is the error: dyld4 config: DYLD_LIBRARY_PATH= /usr/lib/system/introspection DYLD_INSERT_LIBRARIES= /Developer/usr/lib/libBacktraceRecording.dylib: /Developer/usr/lib/libMainThreadChecker.dylib: /Developer/Library/PrivateFrameworks/DTDDISupport.framework/libViewDebuggerSupport.dylib
It doesn't crash on the emulator, but it crashes on a real device.
What am I doing wrong?
Was getting the same thing earlier - it looks like the virtual controller variable is falling out of scope - it eventually tries to call disconnect() but it's no longer there.
I had to define the GCVirtualController as a property of the view controller and this solved it:
var gameController: GCVirtualController?