Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change minimum requirements to Xcode9 / iOS 9 #851

Merged
merged 20 commits into from
Dec 12, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ - (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];
self.title = @"Apple Pay";
if ([self respondsToSelector:@selector(setEdgesForExtendedLayout:)]) {
self.edgesForExtendedLayout = UIRectEdgeNone;
}
self.edgesForExtendedLayout = UIRectEdgeNone;

self.shippingManager = [[ShippingManager alloc] init];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ - (void)viewDidLoad {
[super viewDidLoad];

self.title = @"Card";
if ([self respondsToSelector:@selector(setEdgesForExtendedLayout:)]) {
self.edgesForExtendedLayout = UIRectEdgeNone;
}
self.edgesForExtendedLayout = UIRectEdgeNone;

UIBarButtonItem *buyButton = [[UIBarButtonItem alloc] initWithTitle:@"Pay" style:UIBarButtonItemStyleDone target:self action:@selector(pay)];
buyButton.enabled = NO;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ - (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];
self.title = @"Sofort";
if ([self respondsToSelector:@selector(setEdgesForExtendedLayout:)]) {
self.edgesForExtendedLayout = UIRectEdgeNone;
}
self.edgesForExtendedLayout = UIRectEdgeNone;

UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
[button setTitle:@"Pay with Sofort" forState:UIControlStateNormal];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ - (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];
self.title = @"Card + 3DS";
if ([self respondsToSelector:@selector(setEdgesForExtendedLayout:)]) {
self.edgesForExtendedLayout = UIRectEdgeNone;
}
self.edgesForExtendedLayout = UIRectEdgeNone;

STPPaymentCardTextField *paymentTextField = [[STPPaymentCardTextField alloc] init];
STPCardParams *cardParams = [STPCardParams new];
Expand Down
2 changes: 2 additions & 0 deletions Stripe.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1100,6 +1100,7 @@
C1FEE5941CBFF11400A7632B /* STPPostalCodeValidator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = STPPostalCodeValidator.h; sourceTree = "<group>"; };
C1FEE5951CBFF11400A7632B /* STPPostalCodeValidator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = STPPostalCodeValidator.m; sourceTree = "<group>"; };
C1FEE5981CBFF24000A7632B /* STPPostalCodeValidatorTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = STPPostalCodeValidatorTest.m; sourceTree = "<group>"; };
F10239381FDF4144006273B5 /* FauxPasAnnotations.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = FauxPasAnnotations.h; path = PublicHeaders/FauxPasAnnotations.h; sourceTree = "<group>"; };
F1122A7D1DFB84E000A8B1AF /* UINavigationBar+StripeTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UINavigationBar+StripeTest.m"; sourceTree = "<group>"; };
F12829D81D7747E4008B10D6 /* STPBundleLocator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = STPBundleLocator.h; sourceTree = "<group>"; };
F12829D91D7747E4008B10D6 /* STPBundleLocator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = STPBundleLocator.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1582,6 +1583,7 @@
isa = PBXGroup;
children = (
04CDB4A91A5F30A700B854EE /* Stripe.h */,
F10239381FDF4144006273B5 /* FauxPasAnnotations.h */,
F1728CED1EAAA2D9002E0C29 /* API Bindings */,
F1728CEB1EAAA267002E0C29 /* Categories */,
F1728CEE1EAAA2EA002E0C29 /* Helpers */,
Expand Down
2 changes: 0 additions & 2 deletions Stripe/PKPaymentAuthorizationViewController+Stripe_Blocks.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
#import "STPAPIClient.h"
#import "STPPaymentContext.h"

#define FAUXPAS_IGNORED_IN_FILE(...)
FAUXPAS_IGNORED_IN_FILE(APIAvailability)

NS_ASSUME_NONNULL_BEGIN

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#import "PKPaymentAuthorizationViewController+Stripe_Blocks.h"
#import "STPAPIClient+ApplePay.h"

FAUXPAS_IGNORED_IN_FILE(APIAvailability)

static char kSTPBlockBasedApplePayDelegateAssociatedObjectKey;

Expand Down
40 changes: 40 additions & 0 deletions Stripe/PublicHeaders/FauxPasAnnotations.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//
// FauxPasAnnotations.h
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

// ---
//
// This file defines macros that can be used to suppress
// specific Faux Pas diagnostics within desired units of
// code.
//
// The arguments to the macros should be the short names of
// the rules whose diagnostics should be suppressed. The
// suppression macros should be present _inside_ whichever
// code entity they refer to. For example, if you wish
// to suppress diagnostics from the `NSLogUsed` and
// `DotSyntax` rules within an Objective-C method, you
// would do this:
//
// - (void) myMethod {
// FAUXPAS_IGNORED_IN_METHOD(NSLogUsed, DotSyntax)
//
// NSLog(@"Hello world from %@", self.class);
// }
//
// The FAUXPAS_IGNORED() macro refers to the innermost
// code entity it is contained in (an Obj-C method, a C
// function, or an Obj-C class). This macro cannot be used
// to suppress diagnostics within the whole file. For that,
// use the more explicit FAUXPAS_IGNORED_IN_FILE() macro.
//
// ---
// http://fauxpasapp.com
//

#pragma once

#define FAUXPAS_IGNORED(...)
#define FAUXPAS_IGNORED_IN_FILE(...)
#define FAUXPAS_IGNORED_IN_METHOD(...)
#define FAUXPAS_IGNORED_IN_FUNCTION(...)
#define FAUXPAS_IGNORED_IN_CLASS(...)
#define FAUXPAS_IGNORED_ON_LINE(...)
3 changes: 0 additions & 3 deletions Stripe/PublicHeaders/STPAPIClient+ApplePay.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@

#import "STPAPIClient.h"

#define FAUXPAS_IGNORED_IN_FILE(...)
FAUXPAS_IGNORED_IN_FILE(APIAvailability)

/**
STPAPIClient extensions to create Stripe tokens from Apple Pay PKPayment objects.
*/
Expand Down
2 changes: 0 additions & 2 deletions Stripe/PublicHeaders/STPAPIClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
NS_ASSUME_NONNULL_BEGIN

#define FAUXPAS_IGNORED_ON_LINE(...)
#define FAUXPAS_IGNORED_IN_FILE(...)
FAUXPAS_IGNORED_IN_FILE(APIAvailability)

/**
The current version of this library.
Expand Down
3 changes: 0 additions & 3 deletions Stripe/PublicHeaders/STPAddress.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
// Copyright © 2016 Stripe, Inc. All rights reserved.
//

#define FAUXPAS_IGNORED_IN_METHOD(...)
#define FAUXPAS_IGNORED_ON_LINE(...)

#import <Foundation/Foundation.h>
#import <PassKit/PassKit.h>
#import "STPAPIResponseDecodable.h"
Expand Down
2 changes: 0 additions & 2 deletions Stripe/STPAPIClient+ApplePay.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
#import "STPTelemetryClient.h"
#import "STPToken.h"

FAUXPAS_IGNORED_IN_FILE(APIAvailability)

@implementation STPAPIClient (ApplePay)

- (void)createTokenWithPayment:(PKPayment *)payment completion:(STPTokenCompletionBlock)completion {
Expand Down
12 changes: 4 additions & 8 deletions Stripe/STPAPIClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@
#import "STPCategoryLoader.h"
#endif

#define FAUXPAS_IGNORED_IN_METHOD(...)
FAUXPAS_IGNORED_IN_FILE(APIAvailability)

static NSString * const APIVersion = @"2015-10-12";
static NSString * const APIBaseURL = @"https://api.stripe.com/v1";
static NSString * const APIEndpointToken = @"tokens";
Expand Down Expand Up @@ -222,11 +219,10 @@ + (NSString *)stripeUserAgentDetails {
if (model) {
details[@"model"] = model;
}
if ([[UIDevice currentDevice] respondsToSelector:@selector(identifierForVendor)]) {
NSString *vendorIdentifier = [[[UIDevice currentDevice] performSelector:@selector(identifierForVendor)] performSelector:@selector(UUIDString)];
if (vendorIdentifier) {
details[@"vendor_identifier"] = vendorIdentifier;
}

NSString *vendorIdentifier = [UIDevice currentDevice].identifierForVendor.UUIDString;
if (vendorIdentifier) {
details[@"vendor_identifier"] = vendorIdentifier;
}
return [[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:[details copy] options:(NSJSONWritingOptions)kNilOptions error:NULL] encoding:NSUTF8StringEncoding];
}
Expand Down
11 changes: 4 additions & 7 deletions Stripe/STPAddress.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,16 @@
// Copyright © 2016 Stripe, Inc. All rights reserved.
//

#import "NSDictionary+Stripe.h"
#import "STPAddress.h"

#import <Contacts/Contacts.h>

#import "NSDictionary+Stripe.h"
#import "STPCardValidator.h"
#import "STPEmailAddressValidator.h"
#import "STPPhoneNumberValidator.h"
#import "STPPostalCodeValidator.h"

#import <Contacts/Contacts.h>

#define FAUXPAS_IGNORED_IN_FILE(...)
FAUXPAS_IGNORED_IN_FILE(APIAvailability)

NSString *stringIfHasContentsElseNil(NSString *string);

@interface STPAddress ()
Expand Down Expand Up @@ -235,7 +233,6 @@ - (BOOL)hasPartialPostalAddress {
}

+ (PKAddressField)applePayAddressFieldsFromBillingAddressFields:(STPBillingAddressFields)billingAddressFields {
FAUXPAS_IGNORED_IN_METHOD(APIAvailability);
switch (billingAddressFields) {
case STPBillingAddressFieldsNone:
return PKAddressFieldNone;
Expand Down
2 changes: 2 additions & 0 deletions Stripe/STPCardIOProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
//

#import "STPCardIOProxy.h"

#import "FauxPasAnnotations.h"
#import "STPCardParams.h"
#import "STPAnalyticsClient.h"

Expand Down
19 changes: 6 additions & 13 deletions Stripe/STPFormTextField.m
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,9 @@ - (void)setAutoFormattingBehavior:(STPFormTextFieldAutoFormattingBehavior)autoFo
case STPFormTextFieldAutoFormattingBehaviorNone:
case STPFormTextFieldAutoFormattingBehaviorExpiration:
self.textFormattingBlock = nil;
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
if ([self respondsToSelector:@selector(setTextContentType:)]) {
self.textContentType = nil; FAUXPAS_IGNORED_ON_LINE(APIAvailability);
if (@available(iOS 10, *)) {
self.textContentType = nil;
}
#endif
break;
case STPFormTextFieldAutoFormattingBehaviorCardNumbers:
self.textFormattingBlock = ^NSAttributedString *(NSAttributedString *inputString) {
Expand All @@ -140,11 +138,9 @@ - (void)setAutoFormattingBehavior:(STPFormTextFieldAutoFormattingBehavior)autoFo
}
return [attributedString copy];
};
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
if ([self respondsToSelector:@selector(setTextContentType:)]) {
self.textContentType = UITextContentTypeCreditCardNumber; FAUXPAS_IGNORED_ON_LINE(APIAvailability);
if (@available(iOS 10, *)) {
self.textContentType = UITextContentTypeCreditCardNumber;
}
#endif
break;
case STPFormTextFieldAutoFormattingBehaviorPhoneNumbers: {
WEAK(self);
Expand All @@ -157,11 +153,9 @@ - (void)setAutoFormattingBehavior:(STPFormTextFieldAutoFormattingBehavior)autoFo
NSDictionary *attributes = [[self class] attributesForAttributedString:inputString];
return [[NSAttributedString alloc] initWithString:phoneNumber attributes:attributes];
};
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
if ([self respondsToSelector:@selector(setTextContentType:)]) {
self.textContentType = UITextContentTypeTelephoneNumber; FAUXPAS_IGNORED_ON_LINE(APIAvailability);
if (@available(iOS 10, *)) {
self.textContentType = UITextContentTypeTelephoneNumber;
}
#endif
break;
}
}
Expand Down Expand Up @@ -269,7 +263,6 @@ - (CGRect)editingRectForBounds:(CGRect)bounds {

// Fixes a weird issue related to our custom override of deleteBackwards. This only affects the simulator and iPads with custom keyboards.
- (NSArray *)keyCommands {
FAUXPAS_IGNORED_IN_METHOD(APIAvailability);
return @[[UIKeyCommand keyCommandWithInput:@"\b" modifierFlags:UIKeyModifierCommand action:@selector(commandDeleteBackwards)]];
}

Expand Down
9 changes: 3 additions & 6 deletions Stripe/STPImageLibrary.m
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,9 @@ + (UIImage *)largeShippingImage {

+ (UIImage *)safeImageNamed:(NSString *)imageName
templateIfAvailable:(BOOL)templateIfAvailable {
FAUXPAS_IGNORED_IN_METHOD(APIAvailability);
UIImage *image = nil;
if ([UIImage respondsToSelector:@selector(imageNamed:inBundle:compatibleWithTraitCollection:)]) {
image = [UIImage imageNamed:imageName inBundle:[STPBundleLocator stripeResourcesBundle] compatibleWithTraitCollection:nil];
}

UIImage *image = [UIImage imageNamed:imageName inBundle:[STPBundleLocator stripeResourcesBundle] compatibleWithTraitCollection:nil];

if (image == nil) {
image = [UIImage imageNamed:imageName];
}
Expand All @@ -115,7 +113,6 @@ + (UIImage *)safeImageNamed:(NSString *)imageName
+ (UIImage *)brandImageForCardBrand:(STPCardBrand)brand
template:(BOOL)isTemplate {
BOOL shouldUseTemplate = isTemplate;
FAUXPAS_IGNORED_IN_METHOD(APIAvailability);
NSString *imageName;
switch (brand) {
case STPCardBrandAmex:
Expand Down
9 changes: 2 additions & 7 deletions Stripe/STPPaymentCardTextField.m
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,7 @@ - (void)commonInit {
UIImageView *brandImageView = [[UIImageView alloc] initWithImage:self.brandImage];
brandImageView.contentMode = UIViewContentModeCenter;
brandImageView.backgroundColor = [UIColor clearColor];
if ([brandImageView respondsToSelector:@selector(setTintColor:)]) {
brandImageView.tintColor = self.placeholderColor;
}
brandImageView.tintColor = self.placeholderColor;
self.brandImageView = brandImageView;

STPFormTextField *numberField = [self buildTextField];
Expand Down Expand Up @@ -287,10 +285,7 @@ - (UIColor *)textErrorColor {

- (void)setPlaceholderColor:(UIColor *)placeholderColor {
_placeholderColor = [placeholderColor copy];

if ([self.brandImageView respondsToSelector:@selector(setTintColor:)]) {
self.brandImageView.tintColor = placeholderColor;
}
self.brandImageView.tintColor = placeholderColor;

for (STPFormTextField *field in [self allFields]) {
field.placeholderColor = _placeholderColor;
Expand Down
11 changes: 3 additions & 8 deletions Stripe/STPPaymentContext.m
Original file line number Diff line number Diff line change
Expand Up @@ -239,12 +239,10 @@ - (NSInteger)paymentAmount {
}

- (void)setPaymentSummaryItems:(NSArray<PKPaymentSummaryItem *> *)paymentSummaryItems {
FAUXPAS_IGNORED_IN_METHOD(APIAvailability)
self.paymentAmountModel = [[STPPaymentContextAmountModel alloc] initWithPaymentSummaryItems:paymentSummaryItems];
}

- (NSArray<PKPaymentSummaryItem *> *)paymentSummaryItems {
FAUXPAS_IGNORED_IN_METHOD(APIAvailability)
return [self.paymentAmountModel paymentSummaryItemsWithCurrency:self.paymentCurrency
companyName:self.configuration.companyName
shippingMethod:self.selectedShippingMethod];
Expand Down Expand Up @@ -516,7 +514,6 @@ - (BOOL)requestPaymentShouldPresentShippingViewController {
}

- (void)requestPayment {
FAUXPAS_IGNORED_IN_METHOD(APIAvailability);
WEAK(self);
[[[self.didAppearPromise voidFlatMap:^STPPromise * _Nonnull{
STRONG(self);
Expand Down Expand Up @@ -632,7 +629,6 @@ - (void)didFinishWithStatus:(STPPaymentStatus)status
}

- (PKPaymentRequest *)buildPaymentRequest {
FAUXPAS_IGNORED_IN_METHOD(APIAvailability);
if (!self.configuration.appleMerchantIdentifier || !self.paymentAmount) {
return nil;
}
Expand All @@ -652,17 +648,16 @@ - (PKPaymentRequest *)buildPaymentRequest {
else {
paymentRequest.shippingMethods = self.shippingMethods;
}
if ([paymentRequest respondsToSelector:@selector(shippingType)]) {
paymentRequest.shippingType = [[self class] pkShippingType:self.configuration.shippingType];;
}

paymentRequest.shippingType = [[self class] pkShippingType:self.configuration.shippingType];;

if (self.shippingAddress != nil) {
paymentRequest.shippingContact = [self.shippingAddress PKContactValue];
}
return paymentRequest;
}

+ (PKShippingType)pkShippingType:(STPShippingType)shippingType {
FAUXPAS_IGNORED_IN_METHOD(APIAvailability);
switch (shippingType) {
case STPShippingTypeShipping:
return PKShippingTypeShipping;
Expand Down
3 changes: 0 additions & 3 deletions Stripe/STPPaymentContextAmountModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,11 @@
#import <Foundation/Foundation.h>
#import <PassKit/PassKit.h>

#define FAUXPAS_IGNORED_IN_CLASS(...)

/**
Internal model for STPPaymentContext's `paymentAmount` and
`paymentSummaryItems` properties.
*/
@interface STPPaymentContextAmountModel : NSObject
FAUXPAS_IGNORED_IN_CLASS(APIAvailability)

- (instancetype)initWithAmount:(NSInteger)paymentAmount;
- (instancetype)initWithPaymentSummaryItems:(NSArray<PKPaymentSummaryItem *> *)paymentSummaryItems;
Expand Down
2 changes: 0 additions & 2 deletions Stripe/STPPaymentContextAmountModel.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ @implementation STPPaymentContextAmountModel {
NSArray<PKPaymentSummaryItem *> *_paymentSummaryItems;
}

FAUXPAS_IGNORED_IN_CLASS(APIAvailability)

- (instancetype)initWithAmount:(NSInteger)paymentAmount {
self = [super init];
if (self) {
Expand Down
Loading