## 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](https://github.com/krzysztofzablocki/Sourcery/pull/1188#issue-1828038476) 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](README.md). ## Using Sourcery with Docker You can build Docker container with Sourcery installed using this command: ```console docker build -t sourcery-image . ``` Then you can run this Docker image passing the arguments you'd like: ```console docker run sourcery-image sourcery --help ``` ## Contributing ### Installation of Linux Environment I have installed ubuntu VM through [tart](https://github.com/cirruslabs/tart/issues/62#issuecomment-1225956540) and updated to 22.04 according to [this guide](https://www.linuxtechi.com/upgrade-ubuntu-20-04-to-ubuntu-22-04/). 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](https://github.com/swift-server/swiftly). ### 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](https://code.visualstudio.com/docs/setup/linux), which mentions the following commands: ```bash 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](https://github.com/apple/swift-package-manager/issues/5573). 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.