armadsen / ORSSerialPort

Serial port library for Objective-C and Swift macOS apps
MIT License
751 stars 183 forks source link

Having Issues with ORSSerialPort in Xcode 11 for Mac OS 10.15 #158

Closed gchapel1 closed 4 years ago

gchapel1 commented 4 years ago

As sccxx's answer says, you need to make sure you've included the com.apple.security.device.serial to your sandbox entitlements file. If this doesn't fix the issue, let me know, but I'm going to close this for now.

Originally posted by @armadsen in https://github.com/armadsen/ORSSerialPort/issues/156#issuecomment-605527428

I am having issues opening serial ports using ORSSerialPort in Swift. I am using the serialPortManager to get a list of ports, then allowing a user to select the port to open with a popup button and the baud rate for the port with another popup button. Then the user presses an Open Button to open the port. However every time after I press the "Open" Button, I keep getting the following error.

"SerialPort usbmodem903NTKF843172 encountered an error: Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted" UserInfo={NSFilePath=/dev/cu.usbmodem903NTKF843172, NSLocalizedDescription=Operation not permitted}"

I noticed that you supplied the above answer to another person who has a similar issue. However I am building a Mac OS 10.15 app using Xcode 11. I have never used the entitlements section before and I didn't have this issue before when I wrote a similar app using objective-C in an older version of Xcode. I am using Swift for this app and I can't get it to work.

Any ideas as to why? The NSFilePath appears to be correct. The baud rate has a proper setting. The code compiles without errors. But the serial port fails to open and the above error message is printed in the debug window.

Please help. I am new to coding and I am a bit lost on this issue. I have attached a text file with the Swift source code for my ViewController that controls the interface and opens the serialPort.

ViewControllerSwiftSource.txt

yxq-Jason commented 4 years ago

Hi, I am also use Xcode 11.3 and MacOS 10.15, but when I create new App with swift or Objective-C, the Application source will all generate entitlements file automatically(I don’t know what’s the difference setting in ur Xcode).

And same issue I met before and fixed:

Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"

—> Check sandbox and disable, then port open works.

On May 31, 2020, at 2:52 AM, gchapel1 notifications@github.com wrote:

As sccxx's answer says, you need to make sure you've included the com.apple.security.device.serial to your sandbox entitlements file. If this doesn't fix the issue, let me know, but I'm going to close this for now.

Originally posted by @armadsen https://github.com/armadsen in #156 (comment) https://github.com/armadsen/ORSSerialPort/issues/156#issuecomment-605527428 I am having issues opening serial ports using ORSSerialPort. I am using the serialPortManager to get a list a ports, then allowing a user to select the port to open and the baud rate for the port. Then the user presses the Open Button to open the port. However every time I keep getting the following error.

"SerialPort usbmodem903NTKF843172 encountered an error: Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted" UserInfo={NSFilePath=/dev/cu.usbmodem903NTKF843172, NSLocalizedDescription=Operation not permitted}"

I noticed that you supplied the above answer to another person who has a similar issue. However I am using Mac OS 10.15 and Xcode 11. I have never used the entitlements section before and I didn't have this issue before when I wrote a similar app using objective-C. I am using Swift for this app and I can't get it to work.

Any ideas as to why? The NSFilePath appears to be correct. The baud rate has a proper setting. The code compiles without errors. But the serial port fails to open and the above error message is printed in the debug window.

Please help. I am new to coding and I am a bit lost on this issue.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/armadsen/ORSSerialPort/issues/158, or unsubscribe https://github.com/notifications/unsubscribe-auth/AH524ZPEPZZBK3AH5NP6RV3RUFIVTANCNFSM4NOZ2DPA.

gchapel1 commented 4 years ago

Thanks. Yes I managed to get it working. Xcode was being flakey I guess and wasn't seeing my entitlements file. I removed the sandbox completely and I was fine. Then I added the sand box got out of the app and my entitlements file appeared. I entered the property as instructed and all was well.