Print on imz320 with ios SDK (swift)



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)




                   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 {






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)"

Cagatay Yıldırım
Now i tried with objective-C

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<ZebraPrinterConnection, NSObject> connection = nil;

connection = [[MfiBtPrinterConnection alloc] initWithSerialNumber:yazici] ;

BOOL didOpen = [connection open];

if(didOpen == YES) {

     // NSError *error = nil;

// id<ZebraPrinter,NSObject> 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 ];

// } // } }

Vote up!
Vote down!

Points: 0

You voted ‘up’

Cagatay Yıldırım
i found solution put your

i found solution

put your code inside

  dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)) {


Vote up!
Vote down!

Points: 0

You voted ‘up’

James Landers
Cagatay,I too am trying to


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

Vote up!
Vote down!

Points: 0

You voted ‘up’

Log in to post comments