Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I've just changed to a new MacBook Pro with the M1 chip and I can't build my app on Xcode. I've already updated all cocoaPods and have already installed the sudo gem cocoa pods install command in the terminal with Rosetta. These are the two errors I get and make the build Fail:

'new' is unavailable: You cannot directly instantiate an STPIssuingCardPin
like image 966
Ximena Flores de la Tijera Avatar asked Apr 26 '21 21:04

Ximena Flores de la Tijera


3 Answers

As it stands in April, 2021...

TL;DR

This is happening since Xcode 12.5, fixed in Stripe 21.3.1, backported to 19.4.1, 17.0.3, 15.0.2, and 14.0.1, according to Pull Request #1766 'Fix compatibility with Xcode 12.5', so the solution for most will be to upgrade Stripe to 21.3.1 or above.

Downgrade Xcode

The simplest alternative, of course, if you need this urgently and want a quick and dirty method, is to downgrade to Xcode 12.4. If you just went ahead and upgraded, like I did, not knowing the potential consequences, you can go to Apple's Download 'more' section and get it from there.

Cocoapods

For those of you who are using Cocoapods (eg. React Native starting version 0.60): note that, with the exception of 21.3.1, none of the other Stripe versions listed above appear to be available on Stripe's Cocoapods changelog page, and, according to Issue #1767 'ver 19.4.1 is still missing from Cocoapods and How about 20.1.2?', it appears they won't be, at least not 19.4.1, which is what I needed, as upgrading Stripe above version 19 caused errors with tipsi-stripe, the library I used to implement card payment in my React Native app.

Stripe's up-and-coming RN library

As a side note, Stripe is about to release its React Native (RN) library, and I have signed up to be a collaborator in its private beta progam, reporting smaller cosmetic bugs mainly. It's already so close to completion, that I could successfully replace tipsi-stripe with it. The Stripe version used in the new library is above the latest fix version, so this error is not appearing there anymore.

Edit May 2021

Stripe's RN library is now in public beta; you might want to give it a try: https://github.com/stripe/stripe-react-native

like image 173
benomatis Avatar answered Nov 19 '22 14:11

benomatis


I ran pod update Stripe in the ios folder of my react native project and that resolved the issue by upgrading the Stripe pod from 19.4.0 to 19.4.1.

like image 5
dmc85 Avatar answered Nov 19 '22 13:11

dmc85


Step 1: Install latest version of tipsi-stripe package

"tipsi-stripe": "^9.0.0"

Step 2: Update version Stripe in podfile

pod 'Stripe', '21.4.0'

Step 3: Update platform in podfile and

platform :ios, '11.0'
pod install --repo-update

Step 4: In xcode project -- > Info --> Deployment Target

iOS Deployment Target change to '11.0'

Step 5: Add Empty swift file to your project in Xcode. For example File.swift, after that you should accept modal to create bridge.

step 6: Remove ""$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)"", line from LIBRARY_SEARCH_PATHS in project.pbxproj file.

like image 4
Jebasuthan Avatar answered Nov 19 '22 15:11

Jebasuthan