From 6f8e3713e010d263abf77b891e20fb9cfc2034e3 Mon Sep 17 00:00:00 2001 From: dodikk Date: Mon, 20 Aug 2012 10:38:22 +0300 Subject: [PATCH 1/8] Using safe std::vector instead of malloc. Fixed clang warnings. --- .gitignore | 3 + .../NSString+MD5Addition.h | 0 .../NSString+MD5Addition.m | 12 ++-- .../UIDevice+IdentifierAddition.h | 0 .../UIDevice+IdentifierAddition.mm | 71 +++++++++++-------- 5 files changed, 51 insertions(+), 35 deletions(-) create mode 100644 .gitignore rename {Classes => UIDevice-with-UniqueIdentifier-for-iOS-5}/NSString+MD5Addition.h (100%) rename {Classes => UIDevice-with-UniqueIdentifier-for-iOS-5}/NSString+MD5Addition.m (92%) rename {Classes => UIDevice-with-UniqueIdentifier-for-iOS-5}/UIDevice+IdentifierAddition.h (100%) rename Classes/UIDevice+IdentifierAddition.m => UIDevice-with-UniqueIdentifier-for-iOS-5/UIDevice+IdentifierAddition.mm (61%) diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1d0ea6f --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.svn +._* +.DS_Store diff --git a/Classes/NSString+MD5Addition.h b/UIDevice-with-UniqueIdentifier-for-iOS-5/NSString+MD5Addition.h similarity index 100% rename from Classes/NSString+MD5Addition.h rename to UIDevice-with-UniqueIdentifier-for-iOS-5/NSString+MD5Addition.h diff --git a/Classes/NSString+MD5Addition.m b/UIDevice-with-UniqueIdentifier-for-iOS-5/NSString+MD5Addition.m similarity index 92% rename from Classes/NSString+MD5Addition.m rename to UIDevice-with-UniqueIdentifier-for-iOS-5/NSString+MD5Addition.m index 62abdbc..cdad2ad 100644 --- a/Classes/NSString+MD5Addition.m +++ b/UIDevice-with-UniqueIdentifier-for-iOS-5/NSString+MD5Addition.m @@ -12,21 +12,21 @@ @implementation NSString(MD5Addition) - (NSString *) stringFromMD5{ - + if(self == nil || [self length] == 0) return nil; - + const char *value = [self UTF8String]; - + unsigned char outputBuffer[CC_MD5_DIGEST_LENGTH]; CC_MD5(value, strlen(value), outputBuffer); - + NSMutableString *outputString = [[NSMutableString alloc] initWithCapacity:CC_MD5_DIGEST_LENGTH * 2]; for(NSInteger count = 0; count < CC_MD5_DIGEST_LENGTH; count++){ [outputString appendFormat:@"%02x",outputBuffer[count]]; } - - return [outputString autorelease]; + + return outputString; } @end diff --git a/Classes/UIDevice+IdentifierAddition.h b/UIDevice-with-UniqueIdentifier-for-iOS-5/UIDevice+IdentifierAddition.h similarity index 100% rename from Classes/UIDevice+IdentifierAddition.h rename to UIDevice-with-UniqueIdentifier-for-iOS-5/UIDevice+IdentifierAddition.h diff --git a/Classes/UIDevice+IdentifierAddition.m b/UIDevice-with-UniqueIdentifier-for-iOS-5/UIDevice+IdentifierAddition.mm similarity index 61% rename from Classes/UIDevice+IdentifierAddition.m rename to UIDevice-with-UniqueIdentifier-for-iOS-5/UIDevice+IdentifierAddition.mm index 353b023..c9fafd7 100644 --- a/Classes/UIDevice+IdentifierAddition.m +++ b/UIDevice-with-UniqueIdentifier-for-iOS-5/UIDevice+IdentifierAddition.mm @@ -9,6 +9,8 @@ #import "UIDevice+IdentifierAddition.h" #import "NSString+MD5Addition.h" +#include + #include // Per msqr #include #include @@ -29,48 +31,59 @@ @implementation UIDevice (IdentifierAddition) // Return the local MAC addy // Courtesy of FreeBSD hackers email list // Accidentally munged during previous update. Fixed thanks to erica sadun & mlamb. -- (NSString *) macaddress{ - - int mib[6]; - size_t len; - char *buf; - unsigned char *ptr; - struct if_msghdr *ifm; - struct sockaddr_dl *sdl; +- (NSString *) macaddress +{ + static const unsigned int MIB_SIZE = 6; + int mib[6] = + { + CTL_NET, + AF_ROUTE, + 0, + AF_LINK, + NET_RT_IFLIST + }; - mib[0] = CTL_NET; - mib[1] = AF_ROUTE; - mib[2] = 0; - mib[3] = AF_LINK; - mib[4] = NET_RT_IFLIST; + size_t len = 0; + char *buf = NULL; + unsigned char *ptr = NULL; + struct if_msghdr *ifm = {0}; + struct sockaddr_dl *sdl = {0}; + + std::vector bufGuard; + - if ((mib[5] = if_nametoindex("en0")) == 0) { - printf("Error: if_nametoindex error\n"); - return NULL; + if ((mib[5] = if_nametoindex("en0")) == 0) + { + NSLog(@"Error: if_nametoindex error\n"); + return nil; } - - if (sysctl(mib, 6, NULL, &len, NULL, 0) < 0) { - printf("Error: sysctl, take 1\n"); - return NULL; + if (sysctl(mib, MIB_SIZE, NULL, &len, NULL, 0) < 0) + { + NSLog(@"Error: sysctl, take 1\n"); + return nil; } + - if ((buf = malloc(len)) == NULL) { - printf("Could not allocate memory. error!\n"); - return NULL; + bufGuard.resize( len, 0 ); + if ( 0 == len || bufGuard.empty() ) + { + NSLog( @"Could not allocate memory. error!\n" ); + return nil; } + buf = reinterpret_cast( &bufGuard[ 0 ] ); + - if (sysctl(mib, 6, buf, &len, NULL, 0) < 0) { + if (sysctl(mib, MIB_SIZE, buf, &len, NULL, 0) < 0) + { printf("Error: sysctl, take 2"); - free(buf); return NULL; } - ifm = (struct if_msghdr *)buf; - sdl = (struct sockaddr_dl *)(ifm + 1); - ptr = (unsigned char *)LLADDR(sdl); + ifm = reinterpret_cast( buf ); + sdl = reinterpret_cast(ifm + 1); + ptr = reinterpret_cast( LLADDR(sdl) ); NSString *outstring = [NSString stringWithFormat:@"%02X:%02X:%02X:%02X:%02X:%02X", *ptr, *(ptr+1), *(ptr+2), *(ptr+3), *(ptr+4), *(ptr+5)]; - free(buf); return outstring; } From 852cf3189aa4ec7a45010636efdcbd9b2271edcf Mon Sep 17 00:00:00 2001 From: dodikk Date: Thu, 30 Aug 2012 12:53:24 +0300 Subject: [PATCH 2/8] Removed ignored files --- Classes/.DS_Store | Bin 6148 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 Classes/.DS_Store diff --git a/Classes/.DS_Store b/Classes/.DS_Store deleted file mode 100644 index 5008ddfcf53c02e82d7eee2e57c38e5672ef89f6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0 Date: Tue, 12 Mar 2013 11:10:59 +0200 Subject: [PATCH 3/8] added library project --- .../project.pbxproj | 297 ++++++++++++++++++ .../DeviceUniqueIdentifier-Prefix.pch | 4 + 2 files changed, 301 insertions(+) create mode 100644 DeviceUniqueIdentifier/DeviceUniqueIdentifier.xcodeproj/project.pbxproj create mode 100644 DeviceUniqueIdentifier/DeviceUniqueIdentifier/DeviceUniqueIdentifier-Prefix.pch diff --git a/DeviceUniqueIdentifier/DeviceUniqueIdentifier.xcodeproj/project.pbxproj b/DeviceUniqueIdentifier/DeviceUniqueIdentifier.xcodeproj/project.pbxproj new file mode 100644 index 0000000..0666207 --- /dev/null +++ b/DeviceUniqueIdentifier/DeviceUniqueIdentifier.xcodeproj/project.pbxproj @@ -0,0 +1,297 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 7E16FC2816EF1F3900031889 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7E16FC2716EF1F3900031889 /* Foundation.framework */; }; + 7E16FC3A16EF1F5A00031889 /* NSString+MD5Addition.m in Sources */ = {isa = PBXBuildFile; fileRef = 7E16FC3716EF1F5A00031889 /* NSString+MD5Addition.m */; }; + 7E16FC3B16EF1F5A00031889 /* UIDevice+IdentifierAddition.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7E16FC3916EF1F5A00031889 /* UIDevice+IdentifierAddition.mm */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 7E16FC2216EF1F3900031889 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = "include/${PRODUCT_NAME}"; + dstSubfolderSpec = 16; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 7E16FC2416EF1F3900031889 /* libDeviceUniqueIdentifier.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libDeviceUniqueIdentifier.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 7E16FC2716EF1F3900031889 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; + 7E16FC2B16EF1F3900031889 /* DeviceUniqueIdentifier-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "DeviceUniqueIdentifier-Prefix.pch"; sourceTree = ""; }; + 7E16FC3616EF1F5A00031889 /* NSString+MD5Addition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+MD5Addition.h"; sourceTree = ""; }; + 7E16FC3716EF1F5A00031889 /* NSString+MD5Addition.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+MD5Addition.m"; sourceTree = ""; }; + 7E16FC3816EF1F5A00031889 /* UIDevice+IdentifierAddition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIDevice+IdentifierAddition.h"; sourceTree = ""; }; + 7E16FC3916EF1F5A00031889 /* UIDevice+IdentifierAddition.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "UIDevice+IdentifierAddition.mm"; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 7E16FC2116EF1F3900031889 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 7E16FC2816EF1F3900031889 /* Foundation.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 7E16FC1B16EF1F3900031889 = { + isa = PBXGroup; + children = ( + 7E16FC3516EF1F5A00031889 /* UIDevice-with-UniqueIdentifier-for-iOS-5 */, + 7E16FC2916EF1F3900031889 /* DeviceUniqueIdentifier */, + 7E16FC2616EF1F3900031889 /* Frameworks */, + 7E16FC2516EF1F3900031889 /* Products */, + ); + sourceTree = ""; + }; + 7E16FC2516EF1F3900031889 /* Products */ = { + isa = PBXGroup; + children = ( + 7E16FC2416EF1F3900031889 /* libDeviceUniqueIdentifier.a */, + ); + name = Products; + sourceTree = ""; + }; + 7E16FC2616EF1F3900031889 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 7E16FC2716EF1F3900031889 /* Foundation.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + 7E16FC2916EF1F3900031889 /* DeviceUniqueIdentifier */ = { + isa = PBXGroup; + children = ( + 7E16FC2A16EF1F3900031889 /* Supporting Files */, + ); + path = DeviceUniqueIdentifier; + sourceTree = ""; + }; + 7E16FC2A16EF1F3900031889 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 7E16FC2B16EF1F3900031889 /* DeviceUniqueIdentifier-Prefix.pch */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; + 7E16FC3516EF1F5A00031889 /* UIDevice-with-UniqueIdentifier-for-iOS-5 */ = { + isa = PBXGroup; + children = ( + 7E16FC3616EF1F5A00031889 /* NSString+MD5Addition.h */, + 7E16FC3716EF1F5A00031889 /* NSString+MD5Addition.m */, + 7E16FC3816EF1F5A00031889 /* UIDevice+IdentifierAddition.h */, + 7E16FC3916EF1F5A00031889 /* UIDevice+IdentifierAddition.mm */, + ); + name = "UIDevice-with-UniqueIdentifier-for-iOS-5"; + path = "../UIDevice-with-UniqueIdentifier-for-iOS-5"; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 7E16FC2316EF1F3900031889 /* DeviceUniqueIdentifier */ = { + isa = PBXNativeTarget; + buildConfigurationList = 7E16FC3216EF1F3900031889 /* Build configuration list for PBXNativeTarget "DeviceUniqueIdentifier" */; + buildPhases = ( + 7E16FC2016EF1F3900031889 /* Sources */, + 7E16FC2116EF1F3900031889 /* Frameworks */, + 7E16FC2216EF1F3900031889 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = DeviceUniqueIdentifier; + productName = DeviceUniqueIdentifier; + productReference = 7E16FC2416EF1F3900031889 /* libDeviceUniqueIdentifier.a */; + productType = "com.apple.product-type.library.static"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 7E16FC1C16EF1F3900031889 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0460; + ORGANIZATIONNAME = EmbeddedSources; + }; + buildConfigurationList = 7E16FC1F16EF1F3900031889 /* Build configuration list for PBXProject "DeviceUniqueIdentifier" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = 7E16FC1B16EF1F3900031889; + productRefGroup = 7E16FC2516EF1F3900031889 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 7E16FC2316EF1F3900031889 /* DeviceUniqueIdentifier */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + 7E16FC2016EF1F3900031889 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 7E16FC3A16EF1F5A00031889 /* NSString+MD5Addition.m in Sources */, + 7E16FC3B16EF1F5A00031889 /* UIDevice+IdentifierAddition.mm in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 7E16FC3016EF1F3900031889 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES; + CLANG_ANALYZER_SECURITY_INSECUREAPI_RAND = YES; + CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_CXX0X_EXTENSIONS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_IMPLICIT_SIGN_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES; + CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS = NO; + CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_TREAT_WARNINGS_AS_ERRORS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_MISSING_NEWLINE = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_SIGN_COMPARE = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = ..; + IPHONEOS_DEPLOYMENT_TARGET = 6.1; + ONLY_ACTIVE_ARCH = YES; + OTHER_LDFLAGS = ( + "-all_load", + "-ObjC", + ); + SDKROOT = iphoneos; + }; + name = Debug; + }; + 7E16FC3116EF1F3900031889 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES; + CLANG_ANALYZER_SECURITY_INSECUREAPI_RAND = YES; + CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_CXX0X_EXTENSIONS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_IMPLICIT_SIGN_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES; + CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS = NO; + CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_TREAT_WARNINGS_AS_ERRORS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_MISSING_NEWLINE = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_SIGN_COMPARE = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = ..; + IPHONEOS_DEPLOYMENT_TARGET = 6.1; + OTHER_LDFLAGS = ( + "-all_load", + "-ObjC", + ); + SDKROOT = iphoneos; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 7E16FC3316EF1F3900031889 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + DSTROOT = /tmp/DeviceUniqueIdentifier.dst; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "DeviceUniqueIdentifier/DeviceUniqueIdentifier-Prefix.pch"; + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + }; + name = Debug; + }; + 7E16FC3416EF1F3900031889 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + DSTROOT = /tmp/DeviceUniqueIdentifier.dst; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "DeviceUniqueIdentifier/DeviceUniqueIdentifier-Prefix.pch"; + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 7E16FC1F16EF1F3900031889 /* Build configuration list for PBXProject "DeviceUniqueIdentifier" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 7E16FC3016EF1F3900031889 /* Debug */, + 7E16FC3116EF1F3900031889 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 7E16FC3216EF1F3900031889 /* Build configuration list for PBXNativeTarget "DeviceUniqueIdentifier" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 7E16FC3316EF1F3900031889 /* Debug */, + 7E16FC3416EF1F3900031889 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 7E16FC1C16EF1F3900031889 /* Project object */; +} diff --git a/DeviceUniqueIdentifier/DeviceUniqueIdentifier/DeviceUniqueIdentifier-Prefix.pch b/DeviceUniqueIdentifier/DeviceUniqueIdentifier/DeviceUniqueIdentifier-Prefix.pch new file mode 100644 index 0000000..27c1907 --- /dev/null +++ b/DeviceUniqueIdentifier/DeviceUniqueIdentifier/DeviceUniqueIdentifier-Prefix.pch @@ -0,0 +1,4 @@ +#ifdef __OBJC__ + #import + #import +#endif From 9df70a425ea2dd47ae8b207a4aed1a419e268fd9 Mon Sep 17 00:00:00 2001 From: dodikk Date: Tue, 12 Mar 2013 11:11:40 +0200 Subject: [PATCH 4/8] Added missing UIKit include --- .../UIDevice+IdentifierAddition.h | 1 + 1 file changed, 1 insertion(+) diff --git a/UIDevice-with-UniqueIdentifier-for-iOS-5/UIDevice+IdentifierAddition.h b/UIDevice-with-UniqueIdentifier-for-iOS-5/UIDevice+IdentifierAddition.h index 015a1cb..7680543 100644 --- a/UIDevice-with-UniqueIdentifier-for-iOS-5/UIDevice+IdentifierAddition.h +++ b/UIDevice-with-UniqueIdentifier-for-iOS-5/UIDevice+IdentifierAddition.h @@ -6,6 +6,7 @@ // Copyright 2011 Aurora Apps. All rights reserved. // +#import #import From 93f529dc0d69469219a9d932c3dbe8821ccd9946 Mon Sep 17 00:00:00 2001 From: dodikk Date: Tue, 12 Mar 2013 11:12:12 +0200 Subject: [PATCH 5/8] Fixed clang warnings --- .../UIDevice+IdentifierAddition.mm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/UIDevice-with-UniqueIdentifier-for-iOS-5/UIDevice+IdentifierAddition.mm b/UIDevice-with-UniqueIdentifier-for-iOS-5/UIDevice+IdentifierAddition.mm index c9fafd7..cba0759 100644 --- a/UIDevice-with-UniqueIdentifier-for-iOS-5/UIDevice+IdentifierAddition.mm +++ b/UIDevice-with-UniqueIdentifier-for-iOS-5/UIDevice+IdentifierAddition.mm @@ -51,8 +51,10 @@ - (NSString *) macaddress std::vector bufGuard; + unsigned int en0Index = if_nametoindex("en0"); + mib[5] = static_cast( en0Index ); - if ((mib[5] = if_nametoindex("en0")) == 0) + if ( 0 == en0Index ) { NSLog(@"Error: if_nametoindex error\n"); return nil; From aae8d4b14a54e54268b9c8de9bc7ff638be28b4e Mon Sep 17 00:00:00 2001 From: dodikk Date: Tue, 12 Mar 2013 11:12:29 +0200 Subject: [PATCH 6/8] ignoring xCode workspaces --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 1d0ea6f..6b255f7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ .svn ._* .DS_Store +*xcworkspace* +*xcuserdata* From 079f784b9ea7819e9b7ec67827577e2191626a71 Mon Sep 17 00:00:00 2001 From: dodikk Date: Tue, 12 Mar 2013 11:18:00 +0200 Subject: [PATCH 7/8] made demo project use the library --- UIDeviceAddition.xcodeproj/project.pbxproj | 80 ++++++++++++++----- .../UIDeviceAdditionViewController.m | 2 +- 2 files changed, 59 insertions(+), 23 deletions(-) diff --git a/UIDeviceAddition.xcodeproj/project.pbxproj b/UIDeviceAddition.xcodeproj/project.pbxproj index 80d78b6..f62d364 100644 --- a/UIDeviceAddition.xcodeproj/project.pbxproj +++ b/UIDeviceAddition.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 7EC6EC9E16EF29DB00147147 /* libDeviceUniqueIdentifier.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7EC6EC9B16EF29CB00147147 /* libDeviceUniqueIdentifier.a */; }; C1E8503213FFA4C300B38510 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C1E8503113FFA4C300B38510 /* UIKit.framework */; }; C1E8503413FFA4C300B38510 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C1E8503313FFA4C300B38510 /* Foundation.framework */; }; C1E8503613FFA4C300B38510 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C1E8503513FFA4C300B38510 /* CoreGraphics.framework */; }; @@ -16,11 +17,27 @@ C1E8504513FFA4C300B38510 /* MainWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = C1E8504313FFA4C300B38510 /* MainWindow.xib */; }; C1E8504813FFA4C300B38510 /* UIDeviceAdditionViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C1E8504713FFA4C300B38510 /* UIDeviceAdditionViewController.m */; }; C1E8504B13FFA4C300B38510 /* UIDeviceAdditionViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = C1E8504913FFA4C300B38510 /* UIDeviceAdditionViewController.xib */; }; - C1E8505413FFA51200B38510 /* UIDevice+IdentifierAddition.m in Sources */ = {isa = PBXBuildFile; fileRef = C1E8505313FFA51200B38510 /* UIDevice+IdentifierAddition.m */; }; - C1E8506313FFAB5D00B38510 /* NSString+MD5Addition.m in Sources */ = {isa = PBXBuildFile; fileRef = C1E8506213FFAB5D00B38510 /* NSString+MD5Addition.m */; }; /* End PBXBuildFile section */ +/* Begin PBXContainerItemProxy section */ + 7EC6EC9A16EF29CB00147147 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 7EC6EC9616EF29CB00147147 /* DeviceUniqueIdentifier.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 7E16FC2416EF1F3900031889; + remoteInfo = DeviceUniqueIdentifier; + }; + 7EC6EC9C16EF29D700147147 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 7EC6EC9616EF29CB00147147 /* DeviceUniqueIdentifier.xcodeproj */; + proxyType = 1; + remoteGlobalIDString = 7E16FC2316EF1F3900031889; + remoteInfo = DeviceUniqueIdentifier; + }; +/* End PBXContainerItemProxy section */ + /* Begin PBXFileReference section */ + 7EC6EC9616EF29CB00147147 /* DeviceUniqueIdentifier.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = DeviceUniqueIdentifier.xcodeproj; path = DeviceUniqueIdentifier/DeviceUniqueIdentifier.xcodeproj; sourceTree = ""; }; C1E8502D13FFA4C300B38510 /* UIDeviceAddition.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = UIDeviceAddition.app; sourceTree = BUILT_PRODUCTS_DIR; }; C1E8503113FFA4C300B38510 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; C1E8503313FFA4C300B38510 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; @@ -35,10 +52,6 @@ C1E8504613FFA4C300B38510 /* UIDeviceAdditionViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = UIDeviceAdditionViewController.h; sourceTree = ""; }; C1E8504713FFA4C300B38510 /* UIDeviceAdditionViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = UIDeviceAdditionViewController.m; sourceTree = ""; }; C1E8504A13FFA4C300B38510 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/UIDeviceAdditionViewController.xib; sourceTree = ""; }; - C1E8505213FFA51200B38510 /* UIDevice+IdentifierAddition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "UIDevice+IdentifierAddition.h"; path = "Classes/UIDevice+IdentifierAddition.h"; sourceTree = ""; }; - C1E8505313FFA51200B38510 /* UIDevice+IdentifierAddition.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "UIDevice+IdentifierAddition.m"; path = "Classes/UIDevice+IdentifierAddition.m"; sourceTree = ""; }; - C1E8506113FFAB5D00B38510 /* NSString+MD5Addition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "NSString+MD5Addition.h"; path = "Classes/NSString+MD5Addition.h"; sourceTree = ""; }; - C1E8506213FFAB5D00B38510 /* NSString+MD5Addition.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "NSString+MD5Addition.m"; path = "Classes/NSString+MD5Addition.m"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -46,6 +59,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 7EC6EC9E16EF29DB00147147 /* libDeviceUniqueIdentifier.a in Frameworks */, C1E8503213FFA4C300B38510 /* UIKit.framework in Frameworks */, C1E8503413FFA4C300B38510 /* Foundation.framework in Frameworks */, C1E8503613FFA4C300B38510 /* CoreGraphics.framework in Frameworks */, @@ -55,10 +69,17 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 7EC6EC9716EF29CB00147147 /* Products */ = { + isa = PBXGroup; + children = ( + 7EC6EC9B16EF29CB00147147 /* libDeviceUniqueIdentifier.a */, + ); + name = Products; + sourceTree = ""; + }; C1E8502213FFA4C300B38510 = { isa = PBXGroup; children = ( - C1E8505113FFA4D300B38510 /* Classes */, C1E8503713FFA4C300B38510 /* UIDeviceAddition */, C1E8503013FFA4C300B38510 /* Frameworks */, C1E8502E13FFA4C300B38510 /* Products */, @@ -76,6 +97,7 @@ C1E8503013FFA4C300B38510 /* Frameworks */ = { isa = PBXGroup; children = ( + 7EC6EC9616EF29CB00147147 /* DeviceUniqueIdentifier.xcodeproj */, C1E8503113FFA4C300B38510 /* UIKit.framework */, C1E8503313FFA4C300B38510 /* Foundation.framework */, C1E8503513FFA4C300B38510 /* CoreGraphics.framework */, @@ -108,17 +130,6 @@ name = "Supporting Files"; sourceTree = ""; }; - C1E8505113FFA4D300B38510 /* Classes */ = { - isa = PBXGroup; - children = ( - C1E8505213FFA51200B38510 /* UIDevice+IdentifierAddition.h */, - C1E8505313FFA51200B38510 /* UIDevice+IdentifierAddition.m */, - C1E8506113FFAB5D00B38510 /* NSString+MD5Addition.h */, - C1E8506213FFAB5D00B38510 /* NSString+MD5Addition.m */, - ); - name = Classes; - sourceTree = ""; - }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -133,6 +144,7 @@ buildRules = ( ); dependencies = ( + 7EC6EC9D16EF29D700147147 /* PBXTargetDependency */, ); name = UIDeviceAddition; productName = UIDeviceAddition; @@ -158,6 +170,12 @@ mainGroup = C1E8502213FFA4C300B38510; productRefGroup = C1E8502E13FFA4C300B38510 /* Products */; projectDirPath = ""; + projectReferences = ( + { + ProductGroup = 7EC6EC9716EF29CB00147147 /* Products */; + ProjectRef = 7EC6EC9616EF29CB00147147 /* DeviceUniqueIdentifier.xcodeproj */; + }, + ); projectRoot = ""; targets = ( C1E8502C13FFA4C300B38510 /* UIDeviceAddition */, @@ -165,6 +183,16 @@ }; /* End PBXProject section */ +/* Begin PBXReferenceProxy section */ + 7EC6EC9B16EF29CB00147147 /* libDeviceUniqueIdentifier.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = libDeviceUniqueIdentifier.a; + remoteRef = 7EC6EC9A16EF29CB00147147 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; +/* End PBXReferenceProxy section */ + /* Begin PBXResourcesBuildPhase section */ C1E8502B13FFA4C300B38510 /* Resources */ = { isa = PBXResourcesBuildPhase; @@ -186,13 +214,19 @@ C1E8503F13FFA4C300B38510 /* main.m in Sources */, C1E8504213FFA4C300B38510 /* UIDeviceAdditionAppDelegate.m in Sources */, C1E8504813FFA4C300B38510 /* UIDeviceAdditionViewController.m in Sources */, - C1E8505413FFA51200B38510 /* UIDevice+IdentifierAddition.m in Sources */, - C1E8506313FFAB5D00B38510 /* NSString+MD5Addition.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXSourcesBuildPhase section */ +/* Begin PBXTargetDependency section */ + 7EC6EC9D16EF29D700147147 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = DeviceUniqueIdentifier; + targetProxy = 7EC6EC9C16EF29D700147147 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + /* Begin PBXVariantGroup section */ C1E8503A13FFA4C300B38510 /* InfoPlist.strings */ = { isa = PBXVariantGroup; @@ -230,9 +264,10 @@ GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = DEBUG; GCC_SYMBOLS_PRIVATE_EXTERN = NO; - GCC_VERSION = com.apple.compilers.llvmgcc42; + GCC_VERSION = ""; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = .; IPHONEOS_DEPLOYMENT_TARGET = 4.3; SDKROOT = iphoneos; }; @@ -244,9 +279,10 @@ ARCHS = "$(ARCHS_STANDARD_32_BIT)"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_VERSION = com.apple.compilers.llvmgcc42; + GCC_VERSION = ""; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = .; IPHONEOS_DEPLOYMENT_TARGET = 4.3; OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; SDKROOT = iphoneos; diff --git a/UIDeviceAddition/UIDeviceAdditionViewController.m b/UIDeviceAddition/UIDeviceAdditionViewController.m index 78c8621..5d37be2 100644 --- a/UIDeviceAddition/UIDeviceAdditionViewController.m +++ b/UIDeviceAddition/UIDeviceAdditionViewController.m @@ -7,7 +7,7 @@ // #import "UIDeviceAdditionViewController.h" -#import "UIDevice+IdentifierAddition.h" +#import @implementation UIDeviceAdditionViewController From 15bc386ea5c16a9e9c25837c062324d32f0ad640 Mon Sep 17 00:00:00 2001 From: dodikk Date: Tue, 12 Mar 2013 11:21:15 +0200 Subject: [PATCH 8/8] fixed memory leak --- UIDevice-with-UniqueIdentifier-for-iOS-5/NSString+MD5Addition.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UIDevice-with-UniqueIdentifier-for-iOS-5/NSString+MD5Addition.m b/UIDevice-with-UniqueIdentifier-for-iOS-5/NSString+MD5Addition.m index cdad2ad..4ab2de5 100644 --- a/UIDevice-with-UniqueIdentifier-for-iOS-5/NSString+MD5Addition.m +++ b/UIDevice-with-UniqueIdentifier-for-iOS-5/NSString+MD5Addition.m @@ -21,7 +21,7 @@ - (NSString *) stringFromMD5{ unsigned char outputBuffer[CC_MD5_DIGEST_LENGTH]; CC_MD5(value, strlen(value), outputBuffer); - NSMutableString *outputString = [[NSMutableString alloc] initWithCapacity:CC_MD5_DIGEST_LENGTH * 2]; + NSMutableString *outputString = [ NSMutableString stringWithCapacity:CC_MD5_DIGEST_LENGTH * 2 ]; for(NSInteger count = 0; count < CC_MD5_DIGEST_LENGTH; count++){ [outputString appendFormat:@"%02x",outputBuffer[count]]; }