Is it possible to compile and enable C libraries using the Swift package manager?

I tried just to include the header and c files, but they seem to be ignored

+4
source share
2 answers

it is possible, but the usual way to do this is to define a separate package called "Csomething", where you simply prefix the name of the C library with C capital and post it on Github. Package C should consist only of an empty file Package.swiftand module.modulemap. In module.modulemapyou indicate where the C headers are:

module CPackage [system] {
  header "/usr/local/include/myheader.h"
  link "libraryname"
  export *
}

, CPackage, :

.Package(url: "https://github.com/aleph7/CHDF5.git", majorVersion: 1)

import CPackage

https://github.com/aleph7/CHDF5 C

+3

Source: https://habr.com/ru/post/1620006/


All Articles