This article is all about how can we get mac address of Macintosh via coding. So, before I proceed I would like to inform you that I can only be (as far as I know) by C code. This code works for both iPhone or Mac. This article will provide you step by step guidance from the beginning to the end. Also, you will get the github project as a bounce :)

I am writing this article because I had wasted so much time in order to find a solution and I do not want my fellow developers to do so.

Note: Mac address is basically use for identifying the device. Mac address ought to unique to the desvice.

Starting the mission:

Open Xcode and select Cocoa Application>>Next

get mac address (4)

Name your project e.g. “MacAddressLesson

get mac address (5)

Choose a location to save your project

get mac address (6)

your project now look like this

get mac address (7)

Now we will need to add 2 files in our project.

  1. MacAddressHelper.c
  2. MacAddressHelper.h

Download Link is given at the bottom of this project

IpMacAddressHelper.m will have the code part and MacAddressHelper.h will contain the declaration part, I not go too deep in it and I presume that you know what are .h and .c file means.

Now lets add these files

get mac address (8)

browse the location of the files and add them
Now you will be able to see the files in the Project solution explorer
Now we will use the function provided in the MacAddressHelper.h file whose definition is written in the MacAddressHelper.m file.

Refer the Above Screen Shot

    1. Open AppDelegate.m
    2. Add MacAddressHelper.h in header imports. #import “MacAddressHelper.h”
    3. Add awakeFromNib method in the file and then call the [MacAddressHelper address]; that will return the NSString
    4. do not forget to add a break point in the end of the method to check the macAddress
    5. Hit Command+R to run the application


So here is your Mac address that you can use in your application to identify the device. For any question, please feel free to ask and you may comment your questions below. Your suggestions and feedbacks are also welcome.

Download the Whole Project from here: