From 1900ed0504d32e04f21e8c58001fe939e556c16e Mon Sep 17 00:00:00 2001 From: Adam Wulf Date: Mon, 14 Aug 2017 21:39:35 -0500 Subject: [PATCH 1/3] Fixed build warnings --- .../RMStoreTransactionReceiptVerifier.m | 100 +++++++++--------- 1 file changed, 51 insertions(+), 49 deletions(-) diff --git a/RMStore/Optional/RMStoreTransactionReceiptVerifier.m b/RMStore/Optional/RMStoreTransactionReceiptVerifier.m index e7e06359..ab4a7a45 100644 --- a/RMStore/Optional/RMStoreTransactionReceiptVerifier.m +++ b/RMStore/Optional/RMStoreTransactionReceiptVerifier.m @@ -137,64 +137,66 @@ - (void)verifyRequestData:(NSData*)requestData request.HTTPBody = requestData; static NSString *requestMethod = @"POST"; request.HTTPMethod = requestMethod; - + dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ - NSError *error; - NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:&error]; - dispatch_async(dispatch_get_main_queue(), ^{ - if (!data) - { - RMStoreLog(@"Server Connection Failed"); - NSError *wrapperError = [NSError errorWithDomain:RMStoreErrorDomain code:RMStoreErrorCodeUnableToCompleteVerification userInfo:@{NSUnderlyingErrorKey : error, NSLocalizedDescriptionKey : NSLocalizedStringFromTable(@"Connection to Apple failed. Check the underlying error for more info.", @"RMStore", @"Error description")}]; - if (failureBlock != nil) + NSURLSessionDataTask* task = [[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) { + dispatch_async(dispatch_get_main_queue(), ^{ + if (!data) + { + RMStoreLog(@"Server Connection Failed"); + NSError *wrapperError = [NSError errorWithDomain:RMStoreErrorDomain code:RMStoreErrorCodeUnableToCompleteVerification userInfo:@{NSUnderlyingErrorKey : error, NSLocalizedDescriptionKey : NSLocalizedStringFromTable(@"Connection to Apple failed. Check the underlying error for more info.", @"RMStore", @"Error description")}]; + if (failureBlock != nil) + { + failureBlock(wrapperError); + } + return; + } + NSError *jsonError; + NSDictionary *responseJSON = [NSJSONSerialization JSONObjectWithData:data options:0 error:&jsonError]; + if (!responseJSON) { - failureBlock(wrapperError); + RMStoreLog(@"Failed To Parse Server Response"); + if (failureBlock != nil) + { + failureBlock(jsonError); + } } - return; - } - NSError *jsonError; - NSDictionary *responseJSON = [NSJSONSerialization JSONObjectWithData:data options:0 error:&jsonError]; - if (!responseJSON) - { - RMStoreLog(@"Failed To Parse Server Response"); - if (failureBlock != nil) + + static NSString *statusKey = @"status"; + NSInteger statusCode = [responseJSON[statusKey] integerValue]; + + static NSInteger successCode = 0; + static NSInteger sandboxCode = 21007; + if (statusCode == successCode) { - failureBlock(jsonError); + if (successBlock != nil) + { + successBlock(); + } } - } - - static NSString *statusKey = @"status"; - NSInteger statusCode = [responseJSON[statusKey] integerValue]; - - static NSInteger successCode = 0; - static NSInteger sandboxCode = 21007; - if (statusCode == successCode) - { - if (successBlock != nil) + else if (statusCode == sandboxCode) { - successBlock(); + RMStoreLog(@"Verifying Sandbox Receipt"); + // From: https://developer.apple.com/library/ios/#technotes/tn2259/_index.html + // See also: http://stackoverflow.com/questions/9677193/ios-storekit-can-i-detect-when-im-in-the-sandbox + // Always verify your receipt first with the production URL; proceed to verify with the sandbox URL if you receive a 21007 status code. Following this approach ensures that you do not have to switch between URLs while your application is being tested or reviewed in the sandbox or is live in the App Store. + + static NSString *sandboxURL = @"https://sandbox.itunes.apple.com/verifyReceipt"; + [self verifyRequestData:requestData url:sandboxURL success:successBlock failure:failureBlock]; } - } - else if (statusCode == sandboxCode) - { - RMStoreLog(@"Verifying Sandbox Receipt"); - // From: https://developer.apple.com/library/ios/#technotes/tn2259/_index.html - // See also: http://stackoverflow.com/questions/9677193/ios-storekit-can-i-detect-when-im-in-the-sandbox - // Always verify your receipt first with the production URL; proceed to verify with the sandbox URL if you receive a 21007 status code. Following this approach ensures that you do not have to switch between URLs while your application is being tested or reviewed in the sandbox or is live in the App Store. - - static NSString *sandboxURL = @"https://sandbox.itunes.apple.com/verifyReceipt"; - [self verifyRequestData:requestData url:sandboxURL success:successBlock failure:failureBlock]; - } - else - { - RMStoreLog(@"Verification Failed With Code %ld", (long)statusCode); - NSError *serverError = [NSError errorWithDomain:RMStoreErrorDomain code:statusCode userInfo:nil]; - if (failureBlock != nil) + else { - failureBlock(serverError); + RMStoreLog(@"Verification Failed With Code %ld", (long)statusCode); + NSError *serverError = [NSError errorWithDomain:RMStoreErrorDomain code:statusCode userInfo:nil]; + if (failureBlock != nil) + { + failureBlock(serverError); + } } - } - }); + }); + }]; + + [task resume]; }); } From d9d18d6fdf461584cf2d531a1c179d4e6a1e3d83 Mon Sep 17 00:00:00 2001 From: Adam Wulf Date: Sat, 27 Jan 2018 20:31:21 -0600 Subject: [PATCH 2/3] warnings --- RMStore.xcodeproj/project.pbxproj | 36 +++++++++++++++++-- .../xcshareddata/xcschemes/RMStore.xcscheme | 4 ++- .../xcschemes/RMStoreDemo.xcscheme | 4 ++- .../RMStoreExcludeKeychainTests.xcscheme | 4 ++- RMStore/Optional/RMStoreAppReceiptVerifier.m | 4 +-- .../RMStoreTransactionReceiptVerifier.m | 4 +-- RMStore/RMStore.h | 6 ++-- RMStore/RMStore.m | 23 ++++++++++-- RMStoreDemo/RMStoreViewController.xib | 18 +++++----- 9 files changed, 79 insertions(+), 24 deletions(-) diff --git a/RMStore.xcodeproj/project.pbxproj b/RMStore.xcodeproj/project.pbxproj index f7da0a58..866228b9 100644 --- a/RMStore.xcodeproj/project.pbxproj +++ b/RMStore.xcodeproj/project.pbxproj @@ -420,7 +420,7 @@ A0AF3D0017A802F300D2E836 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0720; + LastUpgradeCheck = 0920; ORGANIZATIONNAME = "Robot Media"; }; buildConfigurationList = A0AF3D0317A802F300D2E836 /* Build configuration list for PBXProject "RMStore" */; @@ -550,25 +550,40 @@ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", "$(inherited)", ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 5.1; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; }; @@ -581,17 +596,32 @@ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = YES; + ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 5.1; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; SDKROOT = iphoneos; VALIDATE_PRODUCT = YES; }; diff --git a/RMStore.xcodeproj/xcshareddata/xcschemes/RMStore.xcscheme b/RMStore.xcodeproj/xcshareddata/xcschemes/RMStore.xcscheme index c9dc8750..9b8b9ab0 100644 --- a/RMStore.xcodeproj/xcshareddata/xcschemes/RMStore.xcscheme +++ b/RMStore.xcodeproj/xcshareddata/xcschemes/RMStore.xcscheme @@ -1,6 +1,6 @@ @@ -56,6 +57,7 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + language = "" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/RMStore.xcodeproj/xcshareddata/xcschemes/RMStoreDemo.xcscheme b/RMStore.xcodeproj/xcshareddata/xcschemes/RMStoreDemo.xcscheme index e727c547..42c59ab4 100644 --- a/RMStore.xcodeproj/xcshareddata/xcschemes/RMStoreDemo.xcscheme +++ b/RMStore.xcodeproj/xcshareddata/xcschemes/RMStoreDemo.xcscheme @@ -1,6 +1,6 @@ @@ -45,6 +46,7 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + language = "" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/RMStore.xcodeproj/xcshareddata/xcschemes/RMStoreExcludeKeychainTests.xcscheme b/RMStore.xcodeproj/xcshareddata/xcschemes/RMStoreExcludeKeychainTests.xcscheme index 26d389d9..a2c80a8e 100644 --- a/RMStore.xcodeproj/xcshareddata/xcschemes/RMStoreExcludeKeychainTests.xcscheme +++ b/RMStore.xcodeproj/xcshareddata/xcschemes/RMStoreExcludeKeychainTests.xcscheme @@ -1,6 +1,6 @@ - + + + + + - - + + + @@ -15,13 +19,11 @@ - - - + - \ No newline at end of file + From 269ddaa0aeea68776c15cff8647ff324e3e4848e Mon Sep 17 00:00:00 2001 From: Serg Date: Fri, 2 Feb 2018 11:21:39 +0700 Subject: [PATCH 3/3] fix one more warning --- RMStore/RMStore.m | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/RMStore/RMStore.m b/RMStore/RMStore.m index 70eb383e..a193805e 100755 --- a/RMStore/RMStore.m +++ b/RMStore/RMStore.m @@ -217,7 +217,9 @@ - (void)addPayment:(NSString*)productIdentifier } #ifdef DEBUG - payment.simulatesAskToBuyInSandbox = YES; + if (@available(iOS 8.3, *)) { + payment.simulatesAskToBuyInSandbox = YES; + } #endif RMAddPaymentParameters *parameters = [[RMAddPaymentParameters alloc] init];