Recently i had a requirement to send unique identifier for device to my web service. I was going through the documentation of UIDevice class at apple’s developers site. Apple has depreceated the “uniqueIdentifier” property from IOS 5 onwards. My application project traget was IOS 5 onwards. I did a search on alternatives on web and forums, got many options. In this post i am not giving any tutorial, just about what option i chose and what silly mistake i made while integrating it into my project. One good option was recommended to me by many sources and after using it i would myself recommend this to others. I read Unique Identifier Is Dead, Long Live Unique Identifier”, author has stated the recommendation provided by apple, its pros and cons and better way to use them. Author has implemented the class that encapsulated all the work of getting and storing identifier. So i would recommend to read that blog.

It was very simple to integrate into project, just need to copy and reference one header and implementation file. So now time to state what silly mistake i made, after integrating those implementation files, i ran my project and got so many errors. I am posting some of errors below:

Undefined symbols for architecture i386:
“_SecItemUpdate”, referenced from:
+[BPXLUUIDHandler storeUUID:] in BPXLUUIDHandler.o
“_SecItemAdd”, referenced from:
+[BPXLUUIDHandler storeUUID:] in BPXLUUIDHandler.o
“_SecItemCopyMatching”, referenced from:
+[BPXLUUIDHandler UUID] in BPXLUUIDHandler.o
+[BPXLUUIDHandler reset] in BPXLUUIDHandler.o
“_SecItemDelete”, referenced from:
+[BPXLUUIDHandler reset] in BPXLUUIDHandler.o
“_kSecAttrAccount”, referenced from:
_CreateKeychainQueryDictionary in BPXLUUIDHandler.o
“_kSecAttrService”, referenced from:
_CreateKeychainQueryDictionary in BPXLUUIDHandler.o
“_kSecClass”, referenced from:
_CreateKeychainQueryDictionary in BPXLUUIDHandler.o
“_kSecClassGenericPassword”, referenced from:
_CreateKeychainQueryDictionary in BPXLUUIDHandler.o
“_kSecReturnAttributes”, referenced from:
+[BPXLUUIDHandler UUID] in BPXLUUIDHandler.o
+[BPXLUUIDHandler reset] in BPXLUUIDHandler.o
“_kSecReturnData”, referenced from:
+[BPXLUUIDHandler UUID] in BPXLUUIDHandler.o
“_kSecValueData”, referenced from:
+[BPXLUUIDHandler storeUUID:] in BPXLUUIDHandler.o

So it seemed “SecItemAdd”, “SecItemUpdate” etc were not being processed or recognized. After experiencing similar “Undefined symbols for architecture i386” errors many times in past, i can tell what could be the primary reason. The most primary cause could be that appropriate framework hasn’t been linked up to target. So my first job was to search on SecItemAdd and all above stuff and look for framework they belong to. It seemed that they belong to security farmework. So once again i happened to forgot including the framework. Once everything goes fine then just do:

import "BPXLUUIDHandler.h"

and

[BPXLUUIDHandler UUID]

So anyone who happens to fall into this pitfall like me, don’t forget to link “Security.framework” to your project target.

Thanks.