Non-modular headers of OpenSSL library when using modulemap for Swift framework
In the end I couldn't find any better solution than listing all necessary headers into module map and rewriting include macros of the SSL library files from <>
syntax to just plain include. I used this little shell script to help me with that:
sed -E -i '' 's/#[[:space:]]*include <openssl\/(.*).h>/#include \"\1\.h"/' $SCRIPT_DIR/../Libraries/openssl/include/openssl/*.h
OpenSSL fails to compile for swift framework
I fixed the compilation issue and was able to access the OpenSSL API's.
I had to make a few changes to the module map file.
//
// module.modulemap
// NiksWay
//
// Created by Suraj Gaikwad on 14/03/22.
//
framework module NiksWay {
umbrella header "NiksWay.h"
export *
module * { export * }
explicit module OpenSSL {
header "pkcs12.h"
header "pem.h"
header "opensslv.h"
header "err.h"
link "libcrypto"
link "openssl"
export *
}
}
Swift compiler error: non-modular header inside framework module
Is your header public?
Select the header file in the project explorer. Then in the section on the right in xcode, you'll notice there is a dropdown next to the target. Change that from "project" to "public". This worked for me.
Wrapping an existing C library as a Framework
One unsatisfying solution is to switch to an XCFramework
comprised of Libraries
instead of Frameworks
.
xcodebuild \
-create-xcframework \
-library <path/to/library> \
-header <path/to/headers> \
-output MyCool.xcframework
Then header search paths work correctly, but you lose the .modulemap
and the nice framework structure that keeps everything together neatly per SDK build.
Related Topics
How to Create a Hotspot Network in iOS App Using Swift
Adding Animation to Tabviews in Swiftui When Switching Between Tabs
Is There a Github Markdown Language Identifier for Swift Code
Set Uitextfield Placeholder Color Programmatically
Using 'If-Case' Format in Boolean Assignment in Swift
Getting Data Out of Nsdata with Swift
How to Apply a Grace Time Using Rx
Make Nstextfield in Nstablecellview Firstresponder()
Best Way to Avoid Capturing a Copy of the Value in Closure
Can a Condition Be Used to Determine the Type of a Generic
Swift:Pause and Resume Nstimer
Why Use an Extra Let Statement Here
Bringing iOS Frameworks Through Carthage in Xcode 12.0
What Does "Arg = Exploded" Mean in Swift Crash Log
How to Set the iOS13 Uisegmentedcontrol Backgroundcolor to White
Swift/Cloudkit: After Record Changed, Upload Triggers "Service Record Changed"