4 Replies
      Latest reply on Feb 11, 2019 9:23 AM by john daniel
      dumbbunny Level 1 Level 1 (0 points)

        Hi,

         

        How do I find the computer's Mac Address (or any other unique identifier) in Objective C? I wish to use it to identify the computer to generate a software licence.

        Thanks,

        Paul

        • Re: Mac Address?
          john daniel Level 3 Level 3 (390 points)

          Look for the function GetPrimaryMACAddress at this URL: https://opensource.apple.com/source/webdavfs/webdavfs-334.2/mount.tproj/EncodedSourceID.c

           

          This is just the first Apple URL that seems to match the place where I found the code I'm using.

          • Re: Mac Address?
            eskimo Apple Staff Apple Staff (11,655 points)

            I wish to use it to identify the computer to generate a software licence.

            FYI, neither MAC addresses not serial numbers are perfect for software licences:

            • In many cases the MAC address is user configurable.

            • Macs can ‘lose’ their serial numbers when the logic board is replaced [1].

            • Logic board replacements will also result in the MAC address changing.

            You’ll find that any other approach you take has similar problems.  Much of this territory is covered by Technote 1103 Uniquely Identifying a Macintosh Computer.

            My only concrete recommendation on this front is that, no matter what approach you choose, you implement a strategy for the user to recover when things go wrong, because things will inevitably go wrong.

            Share and Enjoy

            Quinn “The Eskimo!”
            Apple Developer Relations, Developer Technical Support, Core OS/Hardware
            let myEmail = "eskimo" + "1" + "@apple.com"

            [1] Well, the Mac still has a serial number, you just can’t read it programmatically.

              • Re: Mac Address?
                john daniel Level 3 Level 3 (390 points)

                That is certainly all true. However, it is very rare for a machine to lose its serial number and very unusual for users to change their MAC addresses. This is not a perfect system, but it is best there is.

                 

                I didn't suggest using a serial number on purpose. A serial number is a bit more sensitive. If you are storing either the serial number or the MAC address, locally or especially online, make sure to generate a stable, one-way hash value and use that instead. You don't want to keep personal information. Do a Google search for "GDPR" for more information. As a side benefit, a one-way hash of an empty serial number string will still be valid. I suggest not worrying about people who change their MAC address. They probably aren't buying licenses anyway.