RevenueCat / purchases-ios

In-app purchases and subscriptions made easy. Support for iOS, watchOS, tvOS, macOS, and visionOS.
https://www.revenuecat.com/
MIT License
2.27k stars 303 forks source link

Could be the purchase delegate exists without marking it as Objc and not inherent from NSObject (for example AnyObject) #4066

Open jesus-mg-ios opened 1 month ago

jesus-mg-ios commented 1 month ago

https://github.com/RevenueCat/purchases-ios/blob/dbcfe0ceb55879c98d7069c2c788af90b76b27d7/Sources/Purchasing/Purchases/PurchasesDelegate.swift#L24

Currently, when implementing delegates in Swift for classes that interact with Objective-C, delegates often need to inherit from NSObject and be marked with @objc. This requirement adds boilerplate and limits flexibility, especially when designing Swift-first APIs. This proposal suggests allowing delegates to conform to AnyObject instead, providing more flexibility and aligning with Swift conventions.

Details:

Benefits: Simplifies API design by reducing boilerplate (@objc and NSObject inheritance). Enables better alignment with Swift's type system and safety features. Allow clients not expose strings paths inside the binary (that happens if you have to inherit from NSObject)

RCGitBot commented 1 month ago

👀 We've just linked this issue to our internal tracker and notified the team. Thank you for reporting, we're checking this out!

aboedo commented 1 month ago

this is a great idea, we should modernize the delegate