-
Notifications
You must be signed in to change notification settings - Fork 316
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
Fix: Make RCTransaction public #315
Conversation
… doesn't export macros, so that only SPM processes public headers for public swift files
…or SPM-only stuff
NS_SWIFT_NAME(Purchases.Transaction) | ||
@interface RCTransaction : NSObject | ||
|
||
@property (nonatomic, readonly, copy) NSString *revenueCatId; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one easy way to generate the code for this file, so that you don't have to manually do the conversion into objc, is to make the file public in swift, then go to derived data and look for Purchases-swift.h
. That file is an objc version of the public interface for the framework, you just have to find the class and copy/paste it. then maybe clean it up a bit.
Addresses #314
The issue was
Transaction
was forward-declared, but its implementation wasn't publicly available, so callingpurchaserInfo.nonSubscriptionTransactions
worked, but trying to access properties of the transaction wouldn't work.This is the first public Swift file, so figuring out the best path to make it public was sort of tricky, mostly because of the difference in structure we have between most package managers and SPM.
For most package managers, it's only a matter of declaring the type
public
.However, since SPM isn't compatible with mixed-language frameworks, we separated its code into an objc and a swift target, with the objc target being the public-facing one, which depends on swift.
The issue there is that a public swift file wouldn't be publicly available.
I tried a few approaches:
internal
in swift and then providing a public interface for it is a problem for package managers other than SPM because it effectively generates a duplicated symbol. This doesn't happen if both swift and obj parts are internal, but it's a problem if either of the two is public.@_exported import PurchasesObjc
and@_exported import PurchasesSwift
to expose the public stuff in both. That almost worked, but the objc portion won't build for some reason that escapes me.The current approach is to have:
Public
calledSPMSwiftInterfaces
, for this purpose. It's automatically included in SPM because it's located inPublic
.Public/SPMSwiftInterfaces
in the podspecI think at some point we may want to restructure the project so that there's no difference between SPM and other package managers.