Swift Zebra TcpPrinterConnection Remains Open

53 Views Asked by At

I have successfully implemented the Link OS iOS SDK into my Xcode project.

I created a bridging header for the .h files, and I am able to print successfully to our Zebra Printers

I am having an issue where extra tags are being printed. Explained:

  1. Connection is open with IP and port
  2. ZPL data is sent to printer, and tag prints successfully 
  3. Connection is closed

About 20% of the time, when the app is opened again to the main page, the zebra printer will open the tcp connection and print the same tag again. I am stumped and have no idea what is causing this. Any help is appreciated. I added a time stamp to print on the labels, when the extra tag is printed it's using the time stamp form the original tag printed.

I have already tried the following but the issue is still happening:

  1. Set the TcpPrinterConnection object to nil after closing
  2. Wrapped the function in an autoreleasepool

Code:

autoreleasepool {
    var connection = TcpPrinterConnection.init(address: printerIP, andWithPort: 6101)
    
    if connection!.open() == true {
        do {
            try tool!.sendCommand(writeDate)
            connection!.close()
        } catch {
            connection!.close()
            print(error.localizedDescription)
        }
    }
}
0

There are 0 best solutions below