-
Notifications
You must be signed in to change notification settings - Fork 292
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
Fixes RevenueCat.xcframework.zip so that is compatible as a binaryTarget() in SPM. #2164
Conversation
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.
This is amazing, thank you so much!
I use pre-compiled binaries with Carthage myself Egidio is huge for reducing compile times, and had no idea it was this easy to do with SPM 🤯
It's relatively easy to do with SPM in theory, but in practice it can be a little complicated and requires the project to be structured a certain way. I currently have a private repo to vend out 3rd party frameworks for our builds. However, the best solution would be for RevenueCat and other library providers to vend a separate GitHub repo such as let package = Package(
// ...
dependencies: [
// Build this dependency from source code. Good for Xcode beta releases, or incompatible Swift versions.
.package(url: "https://github.com/RevenueCat/purchases-ios.git", from: "4.15.0"),
// Or, build the dependency from the latest binary xcframework instead (much faster).
.package(url: "https://github.com/RevenueCat/purchases-ios-xcframework.git", from: "4.15.0"),
],
// ...
) When you vend it this way, then you can also directly add the dependency in Xcode without having to use a Package.swift file. Then the developer can just decide which version to build, either the xcframework or from source by changing the source URL. It is relatively easy to automate the generation of releases in the xcframework repo using some simple build scripts and GitHub workflow actions, etc. since it doesn't need to build the source code, just update a checksum and point to the latest URL in the main repo. |
@scogeo Oh wow I just read the issue and I hadn't seen the PR yet, this is amazing! We need to verify that it still works correctly with Carthage after the change, and then it's ready to 🚢 We'll look into the separate repo approach, I didn't know about it! |
We might want to consider vending this as a different |
Actually I think that's a great idea. @scogeo would you be able to make that change? |
@NachoSoto Yes, I can make that change. However, I am a little wary as I'm not sure how Carthage downloads the xcframework.zip files. I moved to SPM for all projects a while ago and haven't looked back. :) But I do know from looking at other projects that build xcframeworks for carthage, that carthage does not care what the name of the file is. I think it is likely that if you have two .xcframework.zip file that carthage will attempt to download both and probably create new issues. Let me do a quick experiment or two with carthage in my forked repo and report back. A final note, the change I am proposing is more consistent with how other 3rd party libraries structure their .xcframwork.zip file. It really just seems to be an artifact of the using |
I did a quick test of this PR with Carthage this evening. So good news is this PR as it currently stands does work with carthage as expected. Again, multiple 3rd party libraries ship their framework .zip files this way. The proposed addition of adding another file in the release named Here's the Cartfile I used for this experiment and ran it with a trivial app that links with an initialized RevenueCat with an empty app id.
I created two releases with a different major release version in my forked repo to test with. I used different version numbers so I could inspect the carthage cache. this is what it contains after running all repo options.
So I wouldn't recommend adding multiple xcframework.zip files in the release. Anyway, I'll leave it up to you on how to proceed with the PR. I think this provides maximum backward compatibility with carthage and forward compatibility with SPM binary targets. |
Closing this as it has diverged from main quite a bit and I have an in-house solution to this as part of my build system. |
Checklist
purchases-android
and hybridsMotivation
This update changes the directory structure of the
RevenueCat.xcframework.zip
file so that is compatible for use with Swift Package Manager as a binary target.Resolves #2163
Description
Only include the
RevenueCat.xcframework
in the final zip file. Other directory are superfluous and not compatible with SPM.Steps to verify.
Build the
RevenueCat.xcframework.zip
file usingbundle exec fastlane ios export_xcframework
. Unzip the resultingRevenueCat.xcframework.zip
file in a temporary directory and verify thatRevenueCat.xcframework
is the only contents.