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

Build error on Xcode 12.5 beta 2 #32

Closed
mattgabriel opened this issue Apr 20, 2021 · 2 comments · Fixed by #33
Closed

Build error on Xcode 12.5 beta 2 #32

mattgabriel opened this issue Apr 20, 2021 · 2 comments · Fixed by #33

Comments

@mattgabriel
Copy link

mattgabriel commented Apr 20, 2021

Error: 'new' is unavailable: You cannot directly instantiate an STPIssuingCardPin

This is using react-native-stripe-payments version 1.0.6. Which requires Stripe ~>19.0.
Apparently Stripe issued a fix for this on version 21.4.0, however when trying to force react-native-stripe-payments to use this latest version (Podfile: pod 'Stripe', '~> 21.4.0') throws the error below:

[!] CocoaPods could not find compatible versions for pod "Stripe":
  In Podfile:
    Stripe (~> 21.4.0)

    react-native-stripe-payments (from `../node_modules/react-native-stripe-payments`) was resolved to 1.0.6, which depends on
      Stripe (~> 19.0)

Specs satisfying the `Stripe (~> 21.4.0), Stripe (~> 19.0)` dependency were found, but they required a higher minimum deployment target.

Any ideas?

@magrinj
Copy link
Contributor

magrinj commented Apr 27, 2021

@mattgabriel You can use patch-package to patch the library and force this one to use Stripe ~> 21.4.0

Some extra changes need to be applied because Stripe is now in Swift.

diff --git a/node_modules/react-native-stripe-payments/ios/StripePayments.h b/node_modules/react-native-stripe-payments/ios/StripePayments.h
index f1d3301..322e3ec 100644
--- a/node_modules/react-native-stripe-payments/ios/StripePayments.h
+++ b/node_modules/react-native-stripe-payments/ios/StripePayments.h
@@ -1,6 +1,6 @@
 #import <Foundation/Foundation.h>
 #import <React/RCTBridgeModule.h>
-#import <Stripe/Stripe.h>
+@import Stripe;
 
 @interface StripePayments : NSObject<RCTBridgeModule, STPAuthenticationContext>
 
diff --git a/node_modules/react-native-stripe-payments/ios/StripePayments.m b/node_modules/react-native-stripe-payments/ios/StripePayments.m
index d0142c2..7261999 100644
--- a/node_modules/react-native-stripe-payments/ios/StripePayments.m
+++ b/node_modules/react-native-stripe-payments/ios/StripePayments.m
@@ -8,7 +8,7 @@ @implementation StripePayments
 
 RCT_EXPORT_METHOD(init:(NSString *)publishableKey)
 {
-    [Stripe setDefaultPublishableKey:publishableKey];
+    [StripeAPI setDefaultPublishableKey:publishableKey];
 }
 
 RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(isCardValid:(NSDictionary *)cardParams)
diff --git a/node_modules/react-native-stripe-payments/react-native-stripe-payments.podspec b/node_modules/react-native-stripe-payments/react-native-stripe-payments.podspec
index 2f2f6a3..7c9b694 100644
--- a/node_modules/react-native-stripe-payments/react-native-stripe-payments.podspec
+++ b/node_modules/react-native-stripe-payments/react-native-stripe-payments.podspec
@@ -19,6 +19,5 @@ Pod::Spec.new do |s|
   s.requires_arc = true
 
   s.dependency "React"
-  s.dependency "Stripe", "~> 19.0"
+  s.dependency "Stripe", "~> 21.4.0"
 end
-

• Create the famous "Dummy" swift file (xcode -> open your project -> right click on the folder named after your project, where Info.plist resides -> new File -> Swift -> say YES when asked for the bridging header)
• Remove the swift-5.0 search path, or you will get an error about undefined symbols (try it if you don't believe me), do this -> react-native-community/upgrade-support#62 (comment)

Ref: https://github.com/agaweb/react-native-stripe#additional-ios-setup

Everything should work after all of this !

@karimApps142
Copy link

I m facing the same issue solved by updating the latest version of the stripe library

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants