Print on imz320 with ios SDK (swift)

E Efkan YILMAZ 3 years 7 months ago
91 3 0

Hi,
 
we want to add zebra sdk our IOS and Android apps.Android was easy it works great.But there is problems in IOS swift.(i use latest sdk 1.4.948)
 
i added libzZSDK_API.a , ExternalAccessory.framework,Quartzcore,UIKIT,foundation,coregraphics  and also
i changed info.plist (Required background modes and Supported external accessory ...) i can see these on capabilities .my code block
  let connection:MfiBtPrinterConnection = MfiBtPrinterConnection(serialNumber: serial)
 
        connection.open()
        if(connection.isConnected())
        {
                   do {
                    //    try SGD.SET("bluetooth.page_scan_window", withValue: "60", andWithPrinterConnection: connection)
                let  printer   =  try ZebraPrinterFactory.getInstance(connection)
                let lang =  printer.getPrinterControlLanguage()
                if(lang != PRINTER_LANGUAGE_CPCL){
                    let tool = printer.getToolsUtil()
                    try  tool.sendCommand(dosya)
                }             
            } catch {
                print(error)
            }
 
               connection.close()
        }

this gives error "Unable to determine printer language" at "let  printer   =  try ZebraPrinterFactory.getInstance(connection)"
when i chance this with "let  printer   =  try ZebraPrinterFactory.getInstance(connection, withPrinterLanguage: PRINTER_LANGUAGE_ZPL)" it works but after this
 
it gives error "Error writing to connection" at " try  tool.sendCommand(dosya)"

Please Register or Login to post a reply

3 Replies

J James Landers

Cagatay,

I too am trying to print to one of the Zebra remote printers, however I cannot find any clear swift examples of how to do this.  Would you be able to share example code on how you connected to and printed to your printer.  Fairly new to swift, so any help is appreciated.

Thank you

C Cagatay Yıldırım

Now i tried with objective-C in a few ways and there was same error

ExternalAccessory-329.10.2/EAOutputStream.m:-[EAOutputStream write:maxLength:] - 283 failed to write because stream does not have space available

​@@

NSString *yazici = @"XXXXJ143901964"; id connection = nil; connection = [[MfiBtPrinterConnection alloc] initWithSerialNumber:yazici] ; BOOL didOpen = [connection open]; if(didOpen == YES) {      // NSError *error = nil; // id printer = [ZebraPrinterFactory getInstance:connection withPrinterLanguage:PRINTER_LANGUAGE_ZPL ]; // if(printer != nil) { // PrinterLanguage language = [printer getPrinterControlLanguage]; NSString *testLabel; testLabel = @"^XA^FO17,16^GB379,371,8^FS^FT65,255^A0N,135,134^FDTEST^FS^XZ"; NSData *data = [NSData dataWithBytes:[testLabel UTF8String] length:[testLabel length]]; [connection write:data error:nil]; // [[printer getToolsUtil] sendCommand:testLabel error:nil ]; // } // } }

C Cagatay Yıldırım

i found solution

put your code inside

  dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)) {

}

CONTACT
Can’t find what you’re looking for?