# Installing Theos

## Linux

{% hint style="warning" %}
This guide will help you install Theos on your Linux machine, Linux within Windows via [Windows Subsystem for Linux](https://docs.microsoft.com/windows/wsl) and [Google Cloud Shell](https://console.cloud.google.com/cloudshell).
{% endhint %}

### Development Platforms

| Platform   | Minimum OS Version     | Supported Targets |
| ---------- | ---------------------- | ----------------- |
| Linux      | Linux Kernel 3.16      | Linux, iOS        |
| Windows 10 | Windows 10 Build 14393 | Linux, iOS        |

### Prerequisites

{% hint style="warning" %}
All the commands shown on the following instructions are meant to be run as the "user" user, *not* **root**. Similarly, Theos is also meant to be run as a normal user, *not* **root.**
{% endhint %}

{% hint style="info" %}
Follow the instructions at <http://apt.llvm.org> to add the correct clang-6.0 source for your Linux distro, then run `sudo apt-get update` to refresh your sources.
{% endhint %}

#### On Linux or WSL:

```
sudo apt-get install fakeroot git perl clang-6.0 build-essential
```

> build-essential or equivalent for your distro.

#### Additionally on WSL:

```
sudo update-alternatives --set fakeroot /usr/bin/fakeroot-tcp
```

#### On Google Cloud Shell:

```
# Setup llvm repository
echo -e "deb http://apt.llvm.org/stretch/ llvm-toolchain-stretch-6.0 main\ndeb-src http://apt.llvm.org/stretch/ llvm-toolchain-stretch-6.0 main" | sudo tee -a /etc/apt/sources.list.d/llvm.list
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo apt update

# Install dependencies
sudo apt install bash clang-6.0 coreutils fakeroot git grep make openssh-client perl rsync sed
```

### Set up the THEOS environment variable

```
echo "export THEOS=~/theos" >> ~/.profile
```

> &#x20;For this change to take effect, you must restart your shell. Open a new tab and do `echo $THEOS` on your shell to check if this is working.

### Clone Theos to the device

```
git clone --recursive https://github.com/theos/theos.git $THEOS
```

### Get the toolchain

```
curl https://kabiroberai.com/toolchain/download.php?toolchain=ios-linux -Lo toolchain.tar.gz
tar xzf toolchain.tar.gz -C $THEOS/toolchain
rm toolchain.tar.gz
```

### Get an iOS SDK

{% hint style="info" %}
You can get patched SDKs from here: <https://github.com/theos/sdks>
{% endhint %}

```
curl -LO https://github.com/theos/sdks/archive/master.zip
TMP=$(mktemp -d)
unzip master.zip -d $TMP
mv $TMP/sdks-master/*.sdk $THEOS/sdks
rm -r master.zip $TMP
```

### Install the Swift toolchain (Optional)

```
curl https://kabiroberai.com/toolchain/download.php?toolchain=swift-ubuntu-latest -Lo swift-toolchain.tar.gz
tar xzf swift-toolchain.tar.gz -C $THEOS/toolchain
rm swift-toolchain.tar.gz
```

{% hint style="warning" %}
Note that the minimum SDK version required to compile Swift code is currently iOS 11.2.
{% endhint %}

## iOS

### Development Platforms

| Platform | Minimum OS Version | Supported Targets |
| -------- | ------------------ | ----------------- |
| iOS      | iOS 5.0            | iOS               |

### Prerequisites

{% hint style="warning" %}
All the commands shown on the following instructions are meant to be run as the "user" user, *not* **root**. Similarly, Theos is also meant to be run as a normal user, *not* **root**.
{% endhint %}

#### Add and install the following in Cydia

1. [Sam Bingner’s Repository](http://repo.bingner.com/)
2. Theos Dependencies

### Set up the THEOS environment variable

```
echo "export THEOS=~/theos" >> ~/.profile
```

> For this change to take effect, you must restart your shell. Kill the terminal app in the App Switcher then reopen the terminal app and do `echo $THEOS` on your shell to check if this is working.

### Clone Theos to the **device**

```
git clone --recursive https://github.com/theos/theos.git $THEOS
```

### Get the toolchain

> Theos Dependencies contains the iOS Toolchain

### Get an iOS SDK

{% hint style="info" %}
You can get patched SDKs from here: <https://github.com/theos/sdks>
{% endhint %}

```
curl -LO https://github.com/theos/sdks/archive/master.zip
TMP=$(mktemp -d)
unzip master.zip -d $TMP
mv $TMP/sdks-master/*.sdk $THEOS/sdks
rm -r master.zip $TMP
```

### Install the Swift toolchain (Optional)

```
curl https://kabiroberai.com/toolchain/download.php?toolchain=swift-ubuntu-latest -Lo swift-toolchain.tar.gz
tar xzf swift-toolchain.tar.gz -C $THEOS/toolchain
rm swift-toolchain.tar.gz
```

{% hint style="warning" %}
Note that the minimum SDK version required to compile Swift code is currently iOS 11.2.
{% endhint %}

## macOS

### Development Platforms

| Platform | Minimum OS Version        | Supported Targets         |
| -------- | ------------------------- | ------------------------- |
| macOS    | Mac OS X Mavericks (10.9) | iOS, macOS, watchOS, tvOS |

### Prerequisites

{% hint style="warning" %}
All the commands shown on the following instructions are meant to be run as the "user" user, *not* **root**. Similarly, Theos is also meant to be run as a normal user, *not* **root**.
{% endhint %}

#### Install the following tools

1. [Homebrew](https://brew.sh/)
2. [Xcode](https://itunes.apple.com/us/app/xcode/id497799835?ls=1\&mt=12) (mandatory)

> After installing the above tools, run `brew install ldid xz`

### Set up the THEOS environment variable

```
echo "export THEOS=~/theos" >> ~/.zprofile
```

{% hint style="info" %}
If you are using macOS 10.14 or older, change `~/.zprofile` to `~/.profile`. The default shell was changed from bash to zsh in macOS 10.15. You can check which one you are using by running `echo $SHELL`.
{% endhint %}

> For this change to take effect, you must restart your shell. Open a new tab and do `echo $THEOS` on your shell to check if this is working.

### Clone Theos to the device

```
git clone --recursive https://github.com/theos/theos.git $THEOS
```

### Get the toolchain

> Xcode includes the toolchain

### Get an iOS SDK

> Xcode always provides the latest iOS SDK, but as of Xcode 7.3, it no longer includes private frameworks you can link against. This may be an issue when developing tweaks. You can get patched SDKs from [the SDKs repository](https://github.com/theos/sdks).

```
curl -LO https://github.com/theos/sdks/archive/master.zip
TMP=$(mktemp -d)
unzip master.zip -d $TMP
mv $TMP/sdks-master/*.sdk $THEOS/sdks
rm -r master.zip $TMP
```

## Windows

{% hint style="danger" %}
In-Progress
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://boernai290.gitbook.io/reimagine/start-using-theos/installing-theos.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
