jedisct1 / swift-sodium

Safe and easy to use crypto for iOS and macOS
ISC License
519 stars 185 forks source link

Clibsodium defined as an explicit module and Clibsodium import statem… #194

Closed FedericoHenze closed 4 years ago

FedericoHenze commented 4 years ago

Fix #190

Clibsodium defined as an explicit module and Clibsodium import statements changes to access the clibsodium via the Sodium framework.

Inspired on:

In order to import C library into Swift, it first need to be be declared as a module. Declaration takes the form of a module map — a file describing headers to import and static libraries to link with. The resulting module may be imported into Swift (natively) and Objective-C.

This way of embedding C library into a framework will work for you in most cases (learn more about this approach here and there). It is totally legit as long as you’re developing some internal framework or simply modularising your application into separate parts. However, it doesn’t work well when you need to ship your library to external users via Carthage, Cocoapods or as a binary. The main reason being that the resulting framework is not portable between computers. When undergoing compilation, your resulting framework is bound to the current location of headers and libraries from module map on your computer. You can use it right away in your project but should you try to send it to somebody else they will not be able to link it to a project because files referenced by module map are no longer accessible.

marcelofabri commented 4 years ago

Curious why this got reverted @jedisct1

jedisct1 commented 4 years ago

Because it didn't compile: https://travis-ci.com/jedisct1/swift-sodium/builds/141938692