Closed zhuyeaini9 closed 5 years ago
Hi @zhuyeaini9 Do you have your sample code hosted somewhere for both of your Mac OS app and terminal app? So I can test both apps myself.
the two code is same,I just changed the SerialPort to support singleton.
the macos console code is very simple:
**import Foundation
print("Hello, World!")
let sp = SerialPort.sharedInstance do { try sp.openPort(path: "/dev/cu.usbserial-DQ007X60") print("ok") } catch{ print("error") }** the result is ok.
the macos cocoa app code is simple also,it just have a button,when click button: **@IBAction func onClickTest(_ sender: NSButton) { let sp = SerialPort.sharedInstance do { try sp.openPort(path: "/dev/cu.usbserial-DQ007X60")
print("ok")
}
catch{
print("error")
}
}**
the result is error.
Hi: I test myself and find that when I turn off App SandBox under project's capablities,it's ok.the cocoa app can open port correctly!!!
Hi: I test myself and find that when I turn off App SandBox under project's capablities,it's ok.the cocoa app can open port correctly!!!
I spend 5 hours, before read this. Thank you for solution.
Macos Mojave Xcode 10.2.1 create a new macos app:
I have enable the hardware->usb in xcode,the entitlements shows com.apple.security.device.usb --- boolean --- YES
the device is connect via usb ok,it shows its name when I input cmd in ternimal:ls /dev/cu.* I use cmd "screen /dev/cu.usbserial-DQ007X60 115200" in bash and it return correct info.
the code I used: do { let sp: SerialPort = SerialPort(path:"/dev/cu.usbserial-DQ007X60") try sp.openPort() print("OK") } catch { print("error") } but the program always print error.
when I create a new macos console app: the same code but it print OK...
why???do I missed some steps?