Skip to content

Instantly share code, notes, and snippets.

@fabianeichinger
Last active February 14, 2019 12:22
Show Gist options
  • Save fabianeichinger/94bf7e7ce9af4b5c1dacfd82456367aa to your computer and use it in GitHub Desktop.
Save fabianeichinger/94bf7e7ce9af4b5c1dacfd82456367aa to your computer and use it in GitHub Desktop.

Compiling Telegram for iOS

Tested only in a simulator.

Compiles the official Telegram iOS Repo on Github as of 9bd7c529b2212b1195d21346bbd7b8c04dfdb8ae.

You'll need an API Key / Hash pair to build a working client.

  1. Clone Telegram repo
$ git clone --recursive https://github.com/peter-iakovlev/Telegram
  1. cd into repo
$ cd Telegram
  1. Create stub for build version scripts
$ mkdir tools
$ echo '#!/bin/bash -c true' > tools/bump_build_number.sh
$ echo '#!/bin/bash -c true' > tools/sync_watch_version.sh
  1. Open the Xcode workspace
$ open Telegram.xcworkspace
  1. Right-click the top-most Telegraph workspace and create a new Header File called config.h with this content:
#ifndef config_h
#define config_h

#define SETUP_API_ID(v) v = <YOUR API ID>;
#define SETUP_API_HASH(v) v = @"<YOUR API HASH>";

#endif /* config_h */
  1. Open LegacyDatabase > TGShareContextSignal.m and replace
#import "../../config.h"

with

#import "../config.h"
@dkwiebe
Copy link

dkwiebe commented Apr 9, 2017

Are you interested in any consulting work with Telegram? Even if you're not I'd be glad to send over something as a way of saying thanks for posting this gist.

@kkct83
Copy link

kkct83 commented Apr 11, 2017

I followed your step, and project builded fine. But after entering Number I got below error, whereas I have already updated the apiId and hashID which I obtained from the telegram site.
[MTRequestMessageService#0x600000894b40 response for 6407694375810775040 is error: 400: API_ID_INVALID]

@fabianeichinger
Copy link
Author

@dkwiebe I'm not at all familiar with the code base, just needed iOS Telegram in a Simulator. But best of luck to you and your fork!

@kkct83 Are you sure you've entered the correct id, hash pair (i.e. the what you got from https://my.telegram.org/apps?)
The compiler would probably complain if not but are the values of the macros of the correct type?

...
#define SETUP_API_ID(v) v = 12345;
#define SETUP_API_HASH(v) v = @"1234567890abcdef1234567890abcdef";
...

@irudoy
Copy link

irudoy commented May 2, 2017

Also, you can try to checkout commit 333b5c0ffc16772ff7387ded34aebce78088c6bb @ https://github.com/peter-iakovlev/MtProtoKit submodule, if you have an ARC issues.

@hieubtcoltech
Copy link

Thank you @fabulant for sharing however I still got error when compiling latest Telegram project. It says SSignalKit/SSignalKit.h not found although I already saw these files in my project

@fabianeichinger
Copy link
Author

@hieubtcoltech I haven't tried it recently. If i find some time I might look into it and update the gist.

@fabianeichinger
Copy link
Author

I updated the Gist so it compiles again after a fresh clone.
You might need to watch out for the Git submodules (I only just now realized that they exist in the project) when you pull changes for this repo.

@sbhmajd
Copy link

sbhmajd commented Feb 21, 2018

Not working anymore,, any other solution?

MTProtoKit using AFNetworking,, old classes AFHTTP.... and AFURLRequest....
Now AFNetworking has AFURLSession....

This one issue of many xD

Moved to TelegramSwift for Mac,,, it is working as Usage description

@yingmu52
Copy link

Here is a working version. 💯

https://github.com/yingmu52/Telegram/tree/public

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment