Skip to content
Tor framework for the iCepa project
Branch: master
Clone or download
Benjamin Erhart
Latest commit 64266b0 Feb 22, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.


Carthage Compatible Travis CI

Tor.framework is the easiest way to embed Tor in your iOS application. The API is not stable yet, and subject to change.

Currently, the framework compiles in static versions of tor, libevent, openssl, and liblzma:

libevent 2.1.8
OpenSSL 1.1.0i
liblzma 5.2.3


  • iOS 8.0 or later
  • Xcode 7.0 or later
  • autoconf, automake, libtool and gettext in your PATH


Embedded frameworks require a minimum deployment target of iOS 8 or OS X Mavericks (10.9).

If you use brew, make sure to install autoconf, automake, libtool and gettext:

brew install automake autoconf libtool gettext

Initial Setup

git clone

cd Tor.framework

git submodule init
git submodule update

carthage build --no-skip-current --platform iOS


To integrate Tor into your Xcode project using Carthage, specify it in your Cartfile:

github "iCepa/Tor.framework" "master"

The above method will configure Carthage to fetch and compile Tor.framework from source. Alternatively, you may use the following to use binary-compiled versions of Tor.framework that correspond to releases in GitHub:

binary "" == 305.8.1

For available precompiled versions, see docs/Tor.json. Since Tor, the Tor.framework release version numbers follow the format "ABB.C.X" for tor version "0.A.B.C" and Tor.framework release X (for that version of Tor). Note that the "BB" slot is a two-digit number, with a leading zero, if necessary. "305.2.1" is the first release from tor

Building a Carthage Binary archive

For maintainers/contributors of Tor.framework, a new precompiled release can be generated by doing the following:

Ensure that you have committed changes to the submodule trees for tor, libevent, openssl, and xz.

In Tor/, increment the TOR_BUNDLE_SHORT_VERSION_STRING version per the format described above. Change TOR_BUNDLE_SHORT_VERSION_DATE to the current date. Commit these changes.

Create a git tag for the version, and then build + archive the framework:

carthage build --no-skip-current

carthage archive Tor

(This generates a file in the repo.)

Then create a release in GitHub which corresponds to the tag, attach the generated to the release.

Add a corresponding entry to docs/Tor.json, commit & push that so that it becomes available at


Starting an instance of Tor involves using three classes: TORThread, TORConfiguration and TORController.

Here is an example of integrating Tor with NSURLSession:

TORConfiguration *configuration = [TORConfiguration new];
configuration.cookieAuthentication = @(YES);
configuration.dataDirectory = [NSURL URLWithString:NSTemporaryDirectory()];
configuration.controlSocket = [configuration.dataDirectory URLByAppendingPathComponent:@"control_port"];
configuration.arguments = @[@"--ignore-missing-torrc"];

TORThread *thread = [[TORThread alloc] initWithConfiguration:configuration];
[thread start];

NSURL *cookieURL = [configuration.dataDirectory URLByAppendingPathComponent:@"control_auth_cookie"];
NSData *cookie = [NSData dataWithContentsOfURL:cookieURL];
TORController *controller = [[TORController alloc] initWithSocketURL:configuration.controlSocket];
[controller authenticateWithData:cookie completion:^(BOOL success, NSError *error) {
    if (!success)

    [controller addObserverForCircuitEstablished:^(BOOL established) {
        if (!established)

        [controller getSessionConfiguration:^(NSURLSessionConfiguration *configuration) {
            NSURLSession *session = [NSURLSession sessionWithConfiguration:configuration];

Known Issues

  • Nobody takes care having it working on MacOS, currently, so builds will probably break on that platform.

  • Carthage warns about the xcconfigs dependency being seemingly unused. It isn't. It's only xcconfig files containing build settings, so nothing actually ends up in the build prodcut. Unfortunately Carthage can't be configured to not throw this warning.


Tor.framework is available under the MIT license. See the LICENSE file for more info.

You can’t perform that action at this time.