diff --git a/OAuth2Client.xcodeproj/project.pbxproj b/OAuth2Client.xcodeproj/project.pbxproj index 9b1d5d82..56ad49bb 100644 --- a/OAuth2Client.xcodeproj/project.pbxproj +++ b/OAuth2Client.xcodeproj/project.pbxproj @@ -414,7 +414,7 @@ 0867D690FE84028FC02AAC07 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0460; + LastUpgradeCheck = 0600; ORGANIZATIONNAME = nxtbgthng; TargetAttributes = { 94B6CE6519C1D0A200AA859B = { @@ -551,7 +551,6 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; CLANG_ENABLE_OBJC_ARC = YES; COPY_PHASE_STRIP = NO; DSTROOT = /tmp/OAuth2Client.dst; @@ -574,7 +573,6 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; CLANG_ENABLE_OBJC_ARC = YES; DSTROOT = /tmp/OAuth2Client.dst; GCC_MODEL_TUNING = G5; @@ -593,7 +591,6 @@ 1DEB922308733DC00010E9CD /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; GCC_C_LANGUAGE_STANDARD = c99; GCC_OPTIMIZATION_LEVEL = 0; GCC_WARN_ABOUT_RETURN_TYPE = YES; @@ -607,7 +604,6 @@ 1DEB922408733DC00010E9CD /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; GCC_C_LANGUAGE_STANDARD = c99; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; @@ -621,7 +617,6 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - ARCHS = "$(ARCHS_STANDARD_64_BIT)"; CLANG_ENABLE_OBJC_ARC = YES; COMBINE_HIDPI_IMAGES = YES; COPY_PHASE_STRIP = NO; @@ -651,7 +646,6 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - ARCHS = "$(ARCHS_STANDARD_64_BIT)"; CLANG_ENABLE_OBJC_ARC = YES; COMBINE_HIDPI_IMAGES = YES; COPY_PHASE_STRIP = YES; diff --git a/Sources/OAuth2Client/NXOAuth2AccessToken.m b/Sources/OAuth2Client/NXOAuth2AccessToken.m index bedef7b8..1e211fcf 100644 --- a/Sources/OAuth2Client/NXOAuth2AccessToken.m +++ b/Sources/OAuth2Client/NXOAuth2AccessToken.m @@ -238,7 +238,7 @@ + (id)tokenFromDefaultKeychainWithServiceProviderName:(NSString *)provider; result = (__bridge_transfer NSDictionary *)cfResult; if (status != noErr) { - NSAssert1(status == errSecItemNotFound, @"unexpected error while fetching token from keychain: %d", (int)status); + NSAssert1(status == errSecItemNotFound, @"unexpected error while fetching token from keychain: %@", @(status)); return nil; } @@ -257,7 +257,7 @@ - (void)storeInDefaultKeychainWithServiceProviderName:(NSString *)provider; nil]; [self removeFromDefaultKeychainWithServiceProviderName:provider]; OSStatus __attribute__((unused)) err = SecItemAdd((__bridge CFDictionaryRef)query, NULL); - NSAssert1(err == noErr, @"error while adding token to keychain: %d", (int)err); + NSAssert1(err == noErr, @"error while adding token to keychain: %@", @(err)); } - (void)removeFromDefaultKeychainWithServiceProviderName:(NSString *)provider; @@ -268,7 +268,7 @@ - (void)removeFromDefaultKeychainWithServiceProviderName:(NSString *)provider; serviceName, kSecAttrService, nil]; OSStatus __attribute__((unused)) err = SecItemDelete((__bridge CFDictionaryRef)query); - NSAssert1((err == noErr || err == errSecItemNotFound), @"error while deleting token from keychain: %d", (int)err); + NSAssert1((err == noErr || err == errSecItemNotFound), @"error while deleting token from keychain: %@", @(err)); } #else @@ -287,7 +287,7 @@ + (id)tokenFromDefaultKeychainWithServiceProviderName:(NSString *)provider; NULL, &item); if (err != noErr) { - NSAssert1(err == errSecItemNotFound, @"unexpected error while fetching token from keychain: %d", err); + NSAssert1(err == errSecItemNotFound, @"unexpected error while fetching token from keychain: %@", @(err)); return nil; } @@ -314,7 +314,7 @@ + (id)tokenFromDefaultKeychainWithServiceProviderName:(NSString *)provider; SecKeychainItemFreeContent(&list, password); } else { // TODO find out why this always works in i386 and always fails on ppc - NSLog(@"Error from SecKeychainItemCopyContent: %d", err); + NSLog(@"Error from SecKeychainItemCopyContent: %@", @(err)); return nil; } CFRelease(item); @@ -336,7 +336,7 @@ OSStatus __attribute__((unused))err = SecKeychainAddGenericPassword(NULL, [data bytes], NULL); - NSAssert1(err == noErr, @"error while adding token to keychain: %d", err); + NSAssert1(err == noErr, @"error while adding token to keychain: %@", @(err)); } - (void)removeFromDefaultKeychainWithServiceProviderName:(NSString *)provider; @@ -351,14 +351,14 @@ - (void)removeFromDefaultKeychainWithServiceProviderName:(NSString *)provider; NULL, NULL, &item); - NSAssert1((err == noErr || err == errSecItemNotFound), @"error while deleting token from keychain: %d", err); + NSAssert1((err == noErr || err == errSecItemNotFound), @"error while deleting token from keychain: %@", @(err)); if (err == noErr) { err = SecKeychainItemDelete(item); } if (item) { CFRelease(item); } - NSAssert1((err == noErr || err == errSecItemNotFound), @"error while deleting token from keychain: %d", err); + NSAssert1((err == noErr || err == errSecItemNotFound), @"error while deleting token from keychain: %@", @(err)); } #endif diff --git a/Sources/OAuth2Client/NXOAuth2AccountStore.m b/Sources/OAuth2Client/NXOAuth2AccountStore.m index 45815ec4..39bf09d8 100644 --- a/Sources/OAuth2Client/NXOAuth2AccountStore.m +++ b/Sources/OAuth2Client/NXOAuth2AccountStore.m @@ -643,7 +643,7 @@ + (void)removeFromDefaultKeychain; serviceName, kSecAttrService, nil]; OSStatus __attribute__((unused)) err = SecItemDelete((__bridge CFDictionaryRef)query); - NSAssert1((err == noErr || err == errSecItemNotFound), @"Error while deleting token from keychain: %zd", err); + NSAssert1((err == noErr || err == errSecItemNotFound), @"Error while deleting token from keychain: %zd", @(err)); } @@ -663,7 +663,7 @@ + (NSDictionary *)accountsFromDefaultKeychain; NULL, &item); if (err != noErr) { - NSAssert1(err == errSecItemNotFound, @"Unexpected error while fetching accounts from keychain: %d", err); + NSAssert1(err == errSecItemNotFound, @"Unexpected error while fetching accounts from keychain: %@", @(err)); return nil; } @@ -690,7 +690,7 @@ + (NSDictionary *)accountsFromDefaultKeychain; SecKeychainItemFreeContent(&list, password); } else { // TODO find out why this always works in i386 and always fails on ppc - NSLog(@"Error from SecKeychainItemCopyContent: %d", err); + NSLog(@"Error from SecKeychainItemCopyContent: %@", @(err)); return nil; } CFRelease(item); @@ -714,7 +714,7 @@ OSStatus __attribute__((unused))err = SecKeychainAddGenericPassword(NULL, [data bytes], NULL); - NSAssert1(err == noErr, @"Error while storing accounts in keychain: %d", err); + NSAssert1(err == noErr, @"Error while storing accounts in keychain: %@", @(err)); } + (void)removeFromDefaultKeychain; @@ -730,14 +730,14 @@ + (void)removeFromDefaultKeychain; NULL, NULL, &item); - NSAssert1((err == noErr || err == errSecItemNotFound), @"Error while deleting accounts from keychain: %d", err); + NSAssert1((err == noErr || err == errSecItemNotFound), @"Error while deleting accounts from keychain: %@", @(err)); if (err == noErr) { err = SecKeychainItemDelete(item); } if (item) { CFRelease(item); } - NSAssert1((err == noErr || err == errSecItemNotFound), @"Error while deleting accounts from keychain: %d", err); + NSAssert1((err == noErr || err == errSecItemNotFound), @"Error while deleting accounts from keychain: %@", @(err)); } #endif diff --git a/Sources/OAuth2Client/NXOAuth2Connection.m b/Sources/OAuth2Client/NXOAuth2Connection.m index a324850b..db188814 100644 --- a/Sources/OAuth2Client/NXOAuth2Connection.m +++ b/Sources/OAuth2Client/NXOAuth2Connection.m @@ -237,7 +237,7 @@ - (void)applyParameters:(NSDictionary *)parameters onRequest:(NSMutableURLReques NSInputStream *postBodyStream = [[NXOAuth2PostBodyStream alloc] initWithParameters:parameters]; contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@",[(NXOAuth2PostBodyStream *)postBodyStream boundary]]; - NSString *contentLength = [NSString stringWithFormat:@"%lld", [(NXOAuth2PostBodyStream *)postBodyStream length]]; + NSString *contentLength = [@([(NXOAuth2PostBodyStream *)postBodyStream length]) stringValue]; [aRequest setValue:contentType forHTTPHeaderField:@"Content-Type"]; [aRequest setValue:contentLength forHTTPHeaderField:@"Content-Length"]; @@ -474,7 +474,7 @@ - (void)connectionDidFinishLoading:(NSURLConnection *)connection; } } - NSString *localizedError = [NSString stringWithFormat:NSLocalizedString(@"HTTP Error: %d", @"NXOAuth2HTTPErrorDomain description"), self.statusCode]; + NSString *localizedError = [NSString stringWithFormat:NSLocalizedString(@"HTTP Error: %@", @"NXOAuth2HTTPErrorDomain description"), self.statusCode]; NSDictionary *errorUserInfo = [NSDictionary dictionaryWithObject:localizedError forKey:NSLocalizedDescriptionKey]; NSError *error = [NSError errorWithDomain:NXOAuth2HTTPErrorDomain code:self.statusCode diff --git a/Sources/OAuth2Client/NXOAuth2PostBodyStream.m b/Sources/OAuth2Client/NXOAuth2PostBodyStream.m index 8b156d84..beec8f71 100644 --- a/Sources/OAuth2Client/NXOAuth2PostBodyStream.m +++ b/Sources/OAuth2Client/NXOAuth2PostBodyStream.m @@ -30,8 +30,7 @@ - (id)initWithParameters:(NSDictionary *)postParameters; { self = [self init]; if (self) { - srandom(time(NULL)); - boundary = [[NSString alloc] initWithFormat:@"------------nx-oauth2%d", rand()]; + boundary = [[NSString alloc] initWithFormat:@"------------nx-oauth2%@", @(arc4random())]; numBytesTotal = 0; streamIndex = 0; @@ -88,7 +87,7 @@ - (NSArray *)streamsForParameters:(NSDictionary *)parameters contentLength:(unsi NSData *delimiterData = [delimiter dataUsingEncoding:NSUTF8StringEncoding]; NSData *contentHeaderData = [[part contentHeaders] dataUsingEncoding:NSUTF8StringEncoding]; - int dataLength = delimiterData.length + contentHeaderData.length; + NSUInteger dataLength = delimiterData.length + contentHeaderData.length; NSMutableData *headerData = [NSMutableData dataWithCapacity: dataLength]; [headerData appendData:delimiterData]; [headerData appendData:contentHeaderData]; @@ -146,7 +145,7 @@ - (NSInteger)read:(uint8_t *)buffer maxLength:(NSUInteger)len; if (currentStream == nil) return 0; - int result = [currentStream read:buffer maxLength:len]; + NSInteger result = [currentStream read:buffer maxLength:len]; if (result == 0) { if (streamIndex < contentStreams.count - 1) { diff --git a/Sources/OAuth2Client/NXOAuth2Request.m b/Sources/OAuth2Client/NXOAuth2Request.m index 6ea973c0..c735c50e 100644 --- a/Sources/OAuth2Client/NXOAuth2Request.m +++ b/Sources/OAuth2Client/NXOAuth2Request.m @@ -163,7 +163,7 @@ - (void)applyParameters:(NSDictionary *)someParameters onRequest:(NSMutableURLRe NSInputStream *postBodyStream = [[NXOAuth2PostBodyStream alloc] initWithParameters:parameters]; NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@", [(NXOAuth2PostBodyStream *)postBodyStream boundary]]; - NSString *contentLength = [NSString stringWithFormat:@"%llu", [(NXOAuth2PostBodyStream *)postBodyStream length]]; + NSString *contentLength = [@([(NXOAuth2PostBodyStream *)postBodyStream length]) stringValue]; [aRequest setValue:contentType forHTTPHeaderField:@"Content-Type"]; [aRequest setValue:contentLength forHTTPHeaderField:@"Content-Length"];