purchases-ios icon indicating copy to clipboard operation
purchases-ios copied to clipboard

RevenueCat.xcframework.zip not compatible with use in SPM binaryTarget()

Open scogeo opened this issue 2 years ago • 5 comments

Describe the bug The RevenueCat.xcframework.zip that is produced for each release is not compatible for use as a binary target in swift package manager. Using a pre-compiled xcframework can substantially cut down on build times for both development and CI environments and increase overall productivity. For example one could define a Package.swift using a binary target and provide the correct checksum for that release:

let package = Package(
/// ....
  targets: [
    /// ...
    .binaryTarget(name: "RevenueCat",
                  url: "https://github.com/RevenueCat/purchases-ios/releases/download/4.15.4/RevenueCat.xcframework.zip",
                  checksum: "<the correct checksum>),
  ],
/// ...
)

SPM requires that the zip file contain only the framework and that the framework is available at the root level of the zip file per Apple's documentation. The current xcframework zip file contains a directory at the root named "xcframeworks" and then multiple sub-directories including the RevenueCat.xcframework below it as follows:

  • (root)
    • xcframeworks
      • archives
      • RevenueCat.dSYMs
      • RevenueCat.xcframework

The directory structure, and the archives and RevenueCat.dSYMs seem to be artifacts of how the xcframework was built using fastlane and are certainly not needed in the final zip. #1118 already included the dSYMs info directly in the xcframework.

The fix is fairly straightforward which is to only include RevenueCat.xcframework directory in the final zip file so the structure would be as follows:

  • (root)
    • RevenueCat.xcframework

This would then be compatible with both SPM and Carthage. Note that I have not tested this with Carthage, but there are other projects that provide Carthage xcframework.zip files that are structured in this manner and compatible with SPM.

I already have a PR to fix the issue that I will submit shortly.

  1. Environment
    1. Platform: iOS 16.x
    2. SDK version: 4.15.4
    3. StoreKit 2 (disabled with useStoreKit2IfEnabled(false)) (Y/N): N/A
    4. OS version: MacOS 13.1 (build environment)
    5. Xcode version: 14.2
    6. How widespread is the issue. Percentage of devices affected.
  2. Debug logs that reproduce the issue
  3. Steps to reproduce, with a description of expected vs. actual behavior
  4. Other information (e.g. stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, etc.)

scogeo avatar Dec 16 '22 00:12 scogeo