How to use SWIFTUI and SWIFT language to call com port?

I can't find any useful help about the content described in the title on Apple's official website. The relevant help on its official website is almost all based on OC language, and even their sample programs are written in OC language. Can I ask if SWIFT can only use the COM port through the bridge of OC-SWIFT?

I don't know if this is still an issue for you but you have the choice of calling C, Objective-C, and now C++ directly from Swift. See what's new in Swift from WWDC23. There is a sample here that will allow you to enumerate serial devices on macOS. That might be a useful place to start. I would place this code in a separate framework and write the appropriate wrapper functions (as needed) to invoke them from SwiftUI or Swift. If you are trying this on iPadOS, forget it. The sample code won't compile for iOS since most of the definitions are missing or not made public for serial device support in IOKit. I was able to test this code with an FT232(USB-C to UART) board and it worked well enough. Also, you can use Serial Tools to make sure the device you want to talk to is supported by the default drivers built into macOS.

How to use SWIFTUI and SWIFT language to call com port?
 
 
Q