Zebra Printer ZD420 Integration & Implementation in iOS (Swift)

Amjad Ali
5 min readSep 17, 2019

--

Let’s start a new Hardware Integration in iOS using Swift language

Before starting the steps of integration, we need to know where this kind of System or applications are used there we need Zebra Printers to be integrated and used??

This kind of Systems are mostly used in Big Garages (Garage Management System), In Education System, and in large Datawarehouse Stores.

However we need to understand the configuration of Zebra Printer ZD420, I will start from the very start for your clear Understanding, from the turning on the zebra Printer

What do we need?

zebra zd420 label printer printing sticker

So from the very start we need to turn on Printer with added LAN and Data of Prineter

After few second this will happen

here we can see three buttons for our understanding giving name them as A, B, C.

“A” is top left button with the shape of play, “B” is middle and “C” top right with X shape

fixing these button in other words configure the data (label) printed from zebra, by pressing B and C for 2 to 3 seconds it will print a sample of IP of that Printer which is very useful for you to match within app when we will discover IP.

By pressing A and C for 2 to 3 seconds it will adjustment/alignment your label which printed previously as a shape of the sample.

So above was a little configuration which you need to understand before integrating the SDK and Implementation of your Z-Printer within the app

Now We need to find SDK of ZEBRA PRINTER ZD420

you can find from here Click the actual SDK given by official website of Zebra Printers now download that loaded SDK, surely It will take time if your connection is good enough else may take much time 😐

Furthermore, after downloading SDK you will find too many files and folders including compress file but here you find one file with name libZDK_API.a

ZD420 Printer SDK

As you know already in the previous Blog that how can we add SDK into our new Project or existing Project well after finding this file simply add into your project

As you know for connecting this SDK we need to add one Bridging-header So it will be work as a bridge and help to integrate this SDK

Example

SDK with Bridging Header

For a moment don’t think about extra files which are used here in this Project step by step you get to know all of these files.

Important

As you need external accessories, you don’t know about it?? Ok don’t worry you need to read Note Important in this my blog here clear mentioned if you have new project that how can you add these required things for integeration of SDK

let's move toward yourprojectname-Bridging-header.h should be named exactly if you have a new project but if you are working on existing where already SDK is integrated and bridging_header is added than what??

Simply Import your files within that existed yourprojectname-Bridging-header.h

Like

Import files in Bridging header file

Now these “ import “etc” ” are files (“etc”) like “GraphicsUtil.h” and all others this all are files which you need to add in the project see “SDK with Bridging Header” figure you can find these files are added in the Project

where can you find these files??

Simply you can find the previous SDK you download or any other resources if not I may able to share with you these files too.

After adding all these files, if you didn’t find any error than Congrats you have integrated you Zebra SDK but if you find an error than please check my previous blog where it is shown what are important things to add in your project for integeration SDK also you need to add something in plist you can check from there we need to move towards code.

Towards Code

Now simply make view controller with name LocalBroadcastViewController and its storyboard to add outlets.

As for me add Tableview in your storyboard make instant of that Tableview into a file and also creat model of DiscoverPrinter with didSet for check if a printer is not nil than reload table view for discovering i .e.

code of instant

Now in the DiscoverPrinter have our IP of Printer if it will not be nill, In other words, if ZebraPrinter is present on the same LAN

Little things need to add in viewdidload for network discovery and local broadcast for fetching the data of that Printer from DiscoveredPrinter

you can able to see here

code of fetching

Above given code is essential to used for fetching the data of Printer for discovering it into table view’s cell

Now the last but not least use extensionof table view for good practice within the class obvious as you know two main Protocols

1: cellForRowAt

2: numberOfRowsInSection

These will be used and in cellForRowAt simply add its common name of Identifier “Cell”

where model id Self.printer[indexPath.row].address because we need Address return cell

And in numberOfRowsInSection make an if statement

if let printers = self.printers

{

return printers.count

}” return 0

here is sample

discovering code

above given code will return the address of the ZebraPrinter connected with your network.

Something is still??

Noo… Congrats it's Discovering IP of Zebra Printer

If you need to know more how to make UI and how to write a code of connecting and print label sample code wise. email me: amjadalie@outlook.com

--

--