IOS library stripe in Swift app leading to unrecognized selection error

I am trying to add Apple Pay to a Swift app using Stripe. I am following > Stripe guide . I've created a demo repo to demonstrate the error I found below.

I added the Stripe library, linked the required Apple libraries, added the Objective-C bridge header, added the Stripe published key, enabled the Stripe Enable ApplePay macro, and enabled the ApplePay entitlement.

The problem comes up when I try to create an actual payment request:

 var request: PKPaymentRequest = Stripe.paymentRequestWithMerchantIdentifier("merchant.fm.kenneth.donate")

      

My repository explains this in detail.

When I create my application, it results in the following error:

2014-11-09 13:59:33.576 stripeTest2[22128:904179] 
+[Stripe paymentRequestWithMerchantIdentifier:]: 
unrecognized selector sent to class 0x10910a210

2014-11-09 13:59:33.579 stripeTest2[22128:904179] *** 
Terminating app due to uncaught exception 'NSInvalidArgumentException', 
reason: '+[Stripe paymentRequestWithMerchantIdentifier:]: 
unrecognized selector sent to class 0x10910a210'

      

My guess is that the problem must be bridging in Objective-C code in the Stripe library. Any help would be greatly appreciated.

+3


source to share


2 answers


This is an interesting case. Seems to __IPHONE_OS_VERSION_MAX_ALLOWED

be undefined for pure-Swift apps, so the ApplePay code won't compile.

Since this check is not strictly necessary (if you are #define STRIPE_ENABLE_APPLEPAY

, but your base SDK is earlier than iOS8 is a programmer's fault), I took these checks from our SDK (I'm an engineer at Stripe). If you take the latest version (2.2.2), everything should work for you (I cloned your repo and tested this change and everything looks fine).



Thank you for getting our attention!

Jack

+3


source


It also helps if I find you add "Stripe + ApplePay.h" to the bridge header.



0


source







All Articles