passepartoutvpn / openssl-apple

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

How to use from Swift macOS app? #62

Open ekscrypto opened 3 months ago

ekscrypto commented 3 months ago

I have a macOS app written in Swift using Xcode 15.3. I'm trying to integrate this openssl-apple package so that I can use it from one of my Swift class.

Step 1: Added this repo to "Package Dependencies", exact version = 3.2.107 Step 2: Selected my app target, confirmed that "Frameworks, Libraries, and Embedded Content" section shows "openssl-apple" static library Step 3: In my class implementation (.swift file), at the top: import openssl

Xcode complains "No such module 'openssl'". If I try "import openssl-apple" I get a "Consecutive statements on a line must be separated by ';'" error.

I tried variations of the name, OpenSSL, opensslapple, etc but nothing seems to work.

The README of this project doesn't provide any example on how to do this. Looking at previous issues, someone recommended adding a Modules/module.modulemap which I've done without any improvement.

Is anyone using this from a macOS Swift app able to provide some guidance? Thanks!

keeshux commented 3 months ago

It's true that a module.modulemap file is clearly missing. It's also true that using OpenSSL from Swift is the ultimate PITA.