Veency Compilation Experience for iPhone


    Despite the fact that Apple provides a fairly complete SDK for the iPhone, sometimes you need an application that goes beyond the documented features. An example of such an application is Veency, a VNC server for jailbroken iPhones.
    I would like to share the experience of compiling Veency from scratch. I hope that this post will be informative.


    It is necessary to make small changes to the VNC server code for the jailbroken iPhone, recompile and install it on the device. There is: a device, Ubuntu 9.04 and a poppy.


    The solution below is not a step-by-step guide. I would like to talk about the assembly process in general and the difficulties that I encountered. Moreover, I tried to collect all the necessary links in this post, as well as lay out some results of my work.


    Saurik (aka Jay Freeman) is the developer of Cydia, Veency, many other iPhone chips and seems to be a very good person.

    SpringBoard is a library that essentially draws the iPhone’s homescreen. It starts with the device.

    toolchain - a set of tools for compiling iPhone applications. We will build it soon.

    libvncserver is an open source VNC server. We will cross-compile it for the iPhone.

    Veency - VNC server for iPhone. We will build it. Salt is in the, the rest is not interesting to us.

    MobileSubstrate- a library written by saurik. In particular, it allows you to run applications in the background. We are interested in the following feature: if you put the library ( dylib) in /Library/MobileSubstrate/DynamicLibraries, it will be loaded when it starts SpringBoard. The product of our experience is Veency.dylibthat which will just lie in DynamicLibraries.

    Step 1: Toolchain for Ubuntu

    It turns out that building a toolchain is not as difficult as it seems. We will build a toolchain for 2.2.1. She will be able to compile applications for 3.0.

    There is such a project, iphonedevonlinux . This, in fact, is one script ./toolchain.shthat downloads almost all the necessary files, scatters everything into folders and collects the toolchain.

    For this script to work, I downloaded: iPhone ipsw version 2.2.1 and Xcode SDK dmg version 2.2.1. Moreover, you must have an account on (it's free). On Ubuntu, you need to have gobjcsome other development utilities. Everything is installed from standard repositories.

    So sudo ./ all.

    Not the first time it worked for me. I met with the following troubles:
    1.*** buffer overflow detected ***: decided apt-get reinstall gcc
    2. cannot compile toolchain/src/cctools/otool/print_objc.c: solved apt-get install libc6
    3. some random error: changed gcc 4.3.3 to gcc 4.2.4. Then I changed it back and it worked. As a result, gcc 4.3.3 compiled.

    When everything is ready, the script will say"All stages completed. The toolchain is ready."

    Step 2: VNC Server

    Everything is simple here. You need to download the libvncserver sources and cross-compile them. Actually, ./configure --host=arm-apple-darwin9and then ordinary make. The only thing that bothered me was that in the main Makefile all kinds of left-handed projects (like libvncclinet, examplesetc.) were being built. I removed them with my hands.
    If you are too lazy to build it yourself, then I posted the library and headers on ifolder .

    When everything is ready, it will appear libvncserver/.lib/libvncserver.dylib.

    Step 3: Veency Makefile

    Saurik, of course, posted his makefile. However, he has this part of his build framework, so it seemed easier for me to write my Makefile, where everything is in one file. I did not encounter any particular difficulties.

    Here is the result of my work: Makefile on pastie .

    Step 4: MobileSubstrate

    Need a header and a library. You can either compile from the repository , or download an already assembled archive . I did the second.

    Step 5: Headers & Frameworks

    Veency build needs headers and frameworks. Which ones are obvious from imports.

    Headers. A dog is buried here. Heders are not easy to find. There is a secret repository where something is stored. There is a class-dump-x program for dumping Objective-C headers. There is a de-compiler ( arm-apple-darwin9-otool), but this should not get there. I want to pay attention to the class GraphicsServices.h: for it, the correct headers turned out to be the most difficult to find (found in the secret repository).

    Frameworks Everything is simple here. If at the linking stage some characters are missing, you can safely copy the frameworks either from the iPhone SDK ( /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.2.1.sdk/System/Library/Frameworks/on the poppy) or scp from the device. The only difficulty: libraries from 3.0 and 2.2.1 should not be mixed.

    Step 6: Make

    If it breaks at the compilation stage, then you need to give missing graders. They must be obtained and added to the inclusion folder ( SB_PATHin the Makefile).
    If it breaks at the linking stage, then you need to add frameworks to $(SYS_PATH)/System/Library( SYS_PATHfrom the Makefile).


    Step 7: Signing

    The assembled library must be signed. There is a utility for this ldid. It is for the desktop and for the iPhone. She didn’t work on my desktop. On iPhone, it is installed from Cydia. Then it’s simple: you need scpVeency.dylibto dial on the device ldid -S Veency.dylib.

    Result: signedVeency.dylib

    Step 8: Installation

    And it's very simple: copy Veency.dylibto /Library/MobileSubstrate/DynamicLibraries. This is automated in the Makefile by target install(you just need to put the IP variable down).

    Result: You are a hacker :)

    About this post

    Do you want to know why I wrote all this? First, share some knowledge. And, secondly, support Habr. Lately, there have been a lot of articles about the fact that Habr is not the one that UFO is already on the moon, that making AI is trivial. A lot of all kinds of idle thoughts, meaningless questions, links to news from other resources, etc. So I want to somehow resist this.

    Reader, please write and you have something about IT. Let on a narrow topic, even if only the tops of ideas, the way is interesting to units. But Habr will have a cake yet!

    Also popular now: