A module for using libuv in Swift language.
Swift-libuv follows the semantic versioning scheme. The API change and backwards compatibility rules are those indicated by SemVer.
You must build libuv before using the module.
$ git clone "https://github.com/Trevi-Swift/swift-libuv.git"
$ cd swift-libuv
$ make all
Or you can build and install libuv manually. But you modify module.modulemap
in this case.
- Clone libuv
cd libuv
sh autogen.sh
./configure --prefix=/usr
make install
(withsudo
as needed)- modify
module.modulemap
:module Libuv [system] { header "/usr/include/uv.h" link "uv" export * }
Add dependency to your Package.swift
file :
import PackageDescription
let package = Package(
dependencies: [
.Package(url: "https://github.com/Trevi-Swift/swift-libuv.git", majorVersion: 1)
]
)
Then you can import the module and use libuv
functions :
import Libuv
let loop = uv_default_loop()
uv_run(loop, UV_RUN_DEFAULT)
print("Event loop: \(loop)")
Warning : You may set the environment variable when executing after building.
$ export LD_LIBRARY_PATH=/path/to/module/lib:"$LD_LIBRARY_PATH"