Skip to content

Latest commit

 

History

History
70 lines (44 loc) · 3.33 KB

LINUX.md

File metadata and controls

70 lines (44 loc) · 3.33 KB

Linux Support

Currently (as per 2.1.0 release), Linux Support is experimental. This means the following:

  1. Running sourcery in the root folder of Sourcery project was generating Equatable.generated.swift and other autogenerated files with extensions of classes used by SourceryRuntime, but they were moved to class definitions due to the abscense of @objc attribute on non-Darwin platforms. Thus, .sourcery.yaml file was disabled for the moment, until #1198 is resolved.
  2. Some unit tests were disabled with #if canImport(ObjectiveC), that is some due to Swift compiler crashes, some due to abscence of JavaScriptCore.
  3. FileWatcher needs to be re-implemented (see this comment for a possible fix)

All issues related to Linux will be mentioned in #1198

Using Sourcery under Linux

Simply add package dependency of Sourcery as described in the README.

Using Sourcery with Docker

You can build Docker container with Sourcery installed using this command:

docker build -t sourcery-image .

Then you can run this Docker image passing the arguments you'd like:

docker run sourcery-image sourcery --help

Contributing

Installation of Linux Environment

I have installed ubuntu VM through tart and updated to 22.04 according to this guide.

I had to run the following commands prior to being able to run bundle install in Sourcery:

  1. sudo apt install libffi-dev
  2. sudo apt install build-essential
  3. sudo apt install libsqlite3-dev
  4. sudo apt-get install libncurses5-dev

Then, swiftly needs to be installed to easily manage Swift installation under Linux. How to install Swiftly is described in this README.

Running Tests Under Linux

To run tests, you can use either Visual Studio Code distribution, or simply swift test in Sourcery root directory.

Visual Studio Code

To install VS Code, you can follow the official guide, which mentions the following commands:

sudo apt-get install wget gpg
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg
sudo install -D -o root -g root -m 644 packages.microsoft.gpg /etc/apt/keyrings/packages.microsoft.gpg
sudo sh -c 'echo "deb [arch=amd64,arm64,armhf signed-by=/etc/apt/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" > /etc/apt/sources.list.d/vscode.list'
rm -f packages.microsoft.gpg

# Then update the package cache and install the package using:

sudo apt install apt-transport-https
sudo apt update
sudo apt install code # or code-insiders

Test Discovery Under Linux

Due to a missing feature in Swift Package Manager, tests under Linux are not discovered if the root class, from which tests are inherited, is located "in another Package/Module". Details regarding this can be found here.

And so, if a new Spec needs to be added, that Spec file needs to be put into LinuxMain.swift similarly to what is there already, mentioning the new class name accordingly.