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

Unable to subclass STPPaymentCardTextField #1768

Closed
mvarie opened this issue Mar 2, 2021 · 11 comments
Closed

Unable to subclass STPPaymentCardTextField #1768

mvarie opened this issue Mar 2, 2021 · 11 comments
Assignees
Labels
triaged Issue has been reviewed by Stripe and is being tracked internally

Comments

@mvarie
Copy link

mvarie commented Mar 2, 2021

Summary

It seems that it is now impossible to subclass STPPaymentCardTextField.

The compile-time error is:

Cannot inherit from non-open class ‘STPPaymentCardTextField’ outside of its defining module

This also makes it impossible to override in a subclass methods that are intended to be overridden by design, such as brandImageForCardBrand, cvcImageForCardBrand, errorImageForCardBrand and others.

Stripe Reference > STPPaymentCardTextField Class Reference > brandImageForCardBrand:
Stripe Reference > STPPaymentCardTextField Class Reference > cvcImageForCardBrand:
Stripe Reference > STPPaymentCardTextField Class Reference > errorImageForCardBrand:

Code to reproduce

class MYPaymentCardTextField: STPPaymentCardTextField{}

Cannot inherit from non-open class ‘STPPaymentCardTextField’ outside of its defining module

iOS version

14.4

Installation method

Swift Package Manager

SDK version

21.3.1

Other information

It didn't happen with SDK version 20.1.1 (which was still objc apparently), it started happening when upgrading from 20.1.1 to 21.3.1.

Class in swift file is marked as public, but it should be probably marked as open. Emphasis mine:

Open access applies only to classes and class members, and it differs from public access by allowing code outside the module to subclass and override, as discussed below in Subclassing. Marking a class as open explicitly indicates that you’ve considered the impact of code from other modules using that class as a superclass, and that you’ve designed your class’s code accordingly.

Source: The Swift Programming Language - Access Control

@csabol-stripe csabol-stripe self-assigned this Mar 3, 2021
@csabol-stripe csabol-stripe added the triaged Issue has been reviewed by Stripe and is being tracked internally label Mar 3, 2021
@csabol-stripe
Copy link
Contributor

Thanks for the report @mvarie, I've got a fix for this that we'll include in the next release

@marcelofabri
Copy link

@csabol-stripe Thanks for looking at this! Is there a timeline for the next release? 🙏

@davidme-stripe
Copy link
Contributor

This should be fixed in 21.4.0.

@marcelofabri
Copy link

21.4.0 doesn't fix it though: fbd12ae only made the class open, but we need the specific methods to be open as well

@davidme-stripe
Copy link
Contributor

Sorry, we totally missed that. :( We'll issue another update very soon.

@BaluNaik
Copy link

@devesh-stripe When we can expect the next release with this fix?

@abusetrouble
Copy link

If I try to subclass this I get exc_bad_access in delegate etc. Is it possible to allow to completely subclass (remove brand image view for example, add floating label) in future releases?

@davidme-stripe
Copy link
Contributor

Please try 21.5.0, this should be fixed.

@BaluNaik
Copy link

BaluNaik commented May 9, 2021

Hey @davidme-stripe
It seems the issue fixed partially, there are few more methods that are not allowing to override.

override func brandImageRect(forBounds bounds: CGRect) -> CGRect

Screen Shot 2021-05-09 at 11 15 07 AM

@marcelofabri
Copy link

Yeah, we also need to override brandImageRect which was previously overridable.

@BaluNaik
Copy link

@davidme-stripe Any update on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triaged Issue has been reviewed by Stripe and is being tracked internally
Projects
None yet
Development

No branches or pull requests

6 participants