I am not aware of any sample code, which is really a shame. Without sample code, writing USB serial device drivers is a very obscure science.
However, if you can influence the code on the USB device you are better off implementing the USB CDC ACM protocol. That way your device appears under /dev/tty* and /dev/cu* without the need to write a device driver. And best of all, it works on Windows and Linux as well - again without device drivers.
And on macOS, you probably don't want to use the /dev/tty* device but rather the /dev/cu* device. /dev/tty* is from the old days when you had a modem connected to your serial port and your software would become active if there was an incoming call.