- Clone the
Swift-Lite-Library-Sample
repo
git clone https://github.com/futurejones/Swift-Lite-Library-Sample.git
- Open the
Sample_Library
directory
cd Swift-Lite-Library-Sample/Sample_Library
- Add any required source files to the
Source
directory - Build the library (NOTE: Change "MyLibrary" to the name of your library)
swiftc -emit-library -emit-module -parse-as-library -module-name MyLibrary Source/*.swift
- Copy the
lib.so
,.swiftdoc
and.swiftmodule
files tomyLibrary/usr/lib/
directory
cp libMyLibrary.so MyLibrary.swiftdoc MyLibrary.swiftmodule myLibrary/usr/lib/
- Rename
myLibrary
directory to the name you want your.deb
package to be called.(NOTE: This can be different to your library name) - Edit the
DEBIAN/control
file as required. - Build the
.deb
package (NOTE: Change "myLibrary" to the name of your library directory)
dpkg-deb --build myLibrary
sudo dpkg -i myLibrary.deb
orsudo dpkg --install myLibrary.deb
- add
import MyLibrary
to your project file.
| // Swift-Lite Module / Library Test
| // type:project
| // name:test.swift
|
| import MyLibrary
|
| hello()
| today()
| printNumbers()
dpkg -r myLibrary
ordpkg --remove myLibrary