Skip to content

Trevi-Swift/swift-libuv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Libuv for Swift

Swift 2.2 Mac OS X Ubuntu Apache 2

Overview

A module for using libuv in Swift language.

Versioning

Swift-libuv follows the semantic versioning scheme. The API change and backwards compatibility rules are those indicated by SemVer.

Installation

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.

  1. Clone libuv
  2. cd libuv
  3. sh autogen.sh
  4. ./configure --prefix=/usr
  5. make install (with sudo as needed)
  6. modify module.modulemap :
        module Libuv [system] {
            header "/usr/include/uv.h"
            link "uv"
            export *
        }

Usage

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"

About

Swift system module for libuv

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages