The link directive specifies only the name of the linked library. That is, it must specify the linker flag suffix for the library. It looks like the directive accepts "-l" and concatenates the name to create the linker flag.
This means that the correct way to specify the map of your module is as follows.
module CGcrypt { header "/Volumes/Xcode/Programme/Swifts/KCAnon/KCAnon_Client/Libs/libgcrypt/gcrypt.h" link "gcrypt" export * }
This will create the linker flag -lgcrypt , which is the correct linker flag.
However, there is another problem that the linker should be able to find the dylib file for gcrypt, and by default it only looks at specific paths. These paths can be found by running clang -Xlinker -v . The output for me is as follows:
tylercloutier$ clang -Xlinker -v @(
Now I'm not sure, but I suspect that the usual search paths are probably
/usr/lib /usr/local/lib
but I think Xcode changed my search paths to indicate MacOSX10.11.sdk/usr/lib , which, by the way, has basically the same set of files as /usr/lib (they are not symbolic). Indeed, in El Capitan, due to System Integrity Protection, even sudo will not allow you to edit /usr/lib .
So the problem I am facing is that even if I installed my libraries in /usr/local/lib , clang will not be able to link them. To fix this, I can explicitly specify the search path.
swift build -Xlinker -L/usr/local/lib/
And we went to the race. I can even create xcodeproj that will have the corresponding linker flag already set in Other Linker Flags .
swift build -Xlinker -L/usr/local/lib/ --generate-xcodeproj
If you do not specify the link directive in the module map file, you can specify it as a flag:
module CGcrypt { header "/Volumes/Xcode/Programme/Swifts/KCAnon/KCAnon_Client/Libs/libgcrypt/gcrypt.h" export * }
In this way
swift build -Xlinker -L/usr/local/lib/ -lgcrypt
How to change the default library search paths, I donβt know. But it would be great if someone else could shed light on this question!