krzyzanowskim / OpenSSL

OpenSSL package for SwiftPM, CocoaPod, and Carthage, multiplatform
https://swift.best
Other
907 stars 334 forks source link

Adjust zip to support binaryTarget when using SPM #155

Closed jonasborsch closed 2 years ago

jonasborsch commented 2 years ago

Hello,

first of all thanks for maintaining this project.

The problem

Currently when using SPM the README suggests to add OpenSSL as a dependency. This will cause SPM to download the whole git repository (which is quite large). To get around that SPM provides the binaryTarget option which also can download remote files via URL. But when trying to use the latest zip file from the releases page, this will not work because of the folder structure inside the zip file.

The latest release looks like this:

image

As you can see the zip contains the whole path to the frameworks of the person who has build the frameworks.

The change

With my change the path will be changed to the Frameworks folder before zip-ing the frameworks.

image

With that the zip can be used as a binaryTarget. Tested only locally so far.

To enrich the usage even further I would love to see a checksum provided which is required when using binaryTarget with a remote URL. At-present getting the checksum requires to download the zip and compute the checksum manually. Having a checksum provided in the release notes would be helpful.

The checksum can be generated with the following command.

swift package compute-checksum Frameworks/OpenSSL.xcframework.zip

If wanted I would suggest to add this as an output to the create-frameworks.sh script for easy copy and paste after building. If there is an automated release process/script, this could also be implemented there.

Please feel free to reach out to me for any questions or feedback. Thanks again for your work :)

krzyzanowskim commented 2 years ago

this will not work because of the folder structure inside the zip file.

Thank you! good catch.

This will cause SPM to download the whole git repository (which is quite large).

the reason why I don't use binary ZIP archive is immature tooling. unfortunately. Xcode tends to fail to download archives (it tends to fail to load git repositories too, just less) and there's nothing I can do about it. I did try it in another project https://github.com/krzyzanowskim/CryptoSwift/releases/tag/1.3.8, then reverted after a wave of problems was reported.

jonasborsch commented 2 years ago

Thanks!

the reason why I don't use binary ZIP archive is immature tooling. unfortunately. Xcode tends to fail to download archives (it tends to fail to load git repositories too, just less) and there's nothing I can do about it.

I totally understand with that. Xcode is one of the reasons why I'm trying to transform from cocoapods to SPM. With SPM I can use CLion or VSCode.