Theos/Setup/iOS

From iPhone Development Wiki
Revision as of 03:57, 13 July 2015 by CodeOriginal (talk | contribs)

This page is for setting up Theos on an iOS Device. For other platforms see Theos/Setup.

Requirements

Mandatory Requirements

  • A jailbroken iOS device with Cydia (or another package manager) installed.

Optional Requirements

  • Knowledge on how to use a command line terminal.
  • Objective C knowledge.
  • OpenSSH installed on your device and a computer that you can SSH into your device with (using MobileTerminal gets tedious pretty quickly).

Installing Theos and it's dependencies

  1. Add the following repositories to your Cydia sources.
  2. Install the following packages in Cydia:
    • Perl
    • Theos
    • iOS Toolchain
  3. Check that Theos is installed on your device by running:
    echo $THEOS

    The output should be: /var/theos

Setting up the iOS SDK

Navigate to http://iphone.howett.net/sdks and check which iOS SDK you wish to download.

  1. Create a directory for the SDK to be placed in:
    mkdir -p $THEOS/sdks
  2. Download the SDK temporarily and extract to the SDK directory:
    curl -ksL "http://iphone.howett.net/sdks/dl/iPhoneOSX.Y.sdk.tbz2" | tar -xj -C $THEOS/sdks

    X.Y being the version numbers of the SDK, as seen in http://iphone.howett.net/sdks.

Additional Step for 64 bit (ARM64) Devices

With the current version of Theos (0.9.639-1), building on ARM64 will throw an error. The following will solve this issue.

  1. Create symlinks to support ARM64:
    ln -s $THEOS/makefiles/platform/Darwin-arm.mk $THEOS/makefiles/platform/Darwin-arm64.mk
    ln -s $THEOS/makefiles/targets/Darwin-arm $THEOS/makefiles/targets/Darwin-arm64

Additional Steps for Ease of Use

Automatically exporting environmental variables

Although exporting $THEOS to /var/theos is not necessary on iOS, it is useful, and tedious to do every time a terminal is opened. To automatically do this, bash's login scripts can be utilized to export these variables. First, the default shell must be changed to bash:

  1. Open the file /etc/master.passwd in a text editor (ifile or vim) and find the lines starting with "mobile" and "root". Change the text at the end of these lines from
    /bin/sh
    to
    /bin/bash
  2. Create a file named .bash_pofile in /var/mobile and add the variables to the file you created. EX:
    export THEOS="/var/theos"

Avoiding using the root user

Using the root user while in a theos project for 'make' commands can cause many issues very quickly.

As your the environment you set up above stands, root is still needed for 'make install'.

To avoid the root user completely, we can bypass this by using ssh keys and remote install.

  1. Follow the guide at http://www.linuxproblem.org/art_9.html to add your ssh keys to the root user for passwordless ss, substituting '[email protected]' for 'a@A' and '[email protected]' for 'b@B'
  2. Open $THEOS/makefiles/Darwin-arm/iphone.mk and near the bottom of the file, find the line
    TARGET_INSTALL_REMOTE := $(_THEOS_FALSE)
    and change it to
    TARGET_INSTALL_REMOTE := $(_THEOS_TRUE)
  3. add this line to the end of ~/.bash_profile
    export THEOS_DEVICE_IP=127.0.0.1

Now 'make package install' may be utilized.