passepartoutvpn / openssl-apple

A script for compiling OpenSSL for Apple Devices.
Apache License 2.0
139 stars 65 forks source link

Swift PM #28

Closed nferruzzi closed 2 years ago

nferruzzi commented 3 years ago

Hello,

I've used your xcframework to make a simple swift binaryTarget pm that is "all inclusive".

https://github.com/nferruzzi/openssl

so basically all you need to use openss is

....
    dependencies: [
        .package(name: "openssl", url: "https://github.com/nferruzzi/openssl", from: "0.0.2"),
    ],
    targets: [
        .target(
            name: "MyApp",
            dependencies: [ .product(name: "OpenSSL", package: "openssl")]),
        .testTarget(
            name: "MyAppTests",
            dependencies: [.product(name: "OpenSSL", package: "openssl")]),
    ]
...

and then you can

import OpenSSL
...

        OpenSSL_SSL_init()
        ERR_load_CRYPTO_strings()

etc etc

would you be interested in adding a concept like this directly to your repo ? at the end what is really required is an URL to the latest openlssl.xcframework.zip which can be hosted by github as a release file.

keeshux commented 3 years ago

There's certainly room for a PR. Is SPM ready for iOS as of yet? I haven't followed the topic in a while.

nferruzzi commented 3 years ago

I think it is, I've been using it since xcode 11 on my apps without major problems, but I`ve tested this specific package with xcode 12.2 only and so far got no problems, both on mac and ios

keeshux commented 3 years ago

The main difference would be, however, that such a package would be binary, whereas the intent of the podspec is compiling OpenSSL locally. Is it something that can be done with SwiftPM?

nferruzzi commented 3 years ago

I've not much of experience compiling C libs with SPM , but from what Ive seen compiling C files is doable but there is no room for scripts and basically no room for passing options to the compiler (just #define) without getting the package marked as unsafe (denying it the ability to be referenced by other Packages). Also, you can specify settings for specific platforms (ie macos, tvos) but not for their architecture (x86, arm).

https://docs.swift.org/package-manager/PackageDescription/PackageDescription.html#csetting https://developer.apple.com/documentation/swift_packages/buildsettingcondition

keeshux commented 3 years ago

Okay, I'll leave it up for discussion for now. I'm certainly willing to move out from CocoaPods sooner or later, so feel free to post updates on this thread.

Thank you very much!

keeshux commented 2 years ago

A Swift package is now available (1.1.1l), though I'm struggling myself with a Bitcode issue.