presets   chat   music   threads  
Tutorial: How to compile Objective-C code
deer

EQE exposes a lot of stuff with Lua scripting. Probably more than enough for most purposes. But there are some instances when writing Objective-C code is the only option.

Unfortunately Objective-C isn't as noob-friendly as Lua. In Lua all you have to do is write the code, then run it. In Objective-C there is a middle step called compiling.

In order to compile code you have to install a bunch of programs (called a toolchain) that turns Objective-C code into a format that only the computer can read. This is why when you view the contents of a .exe file on Windows or a .dylib on iOS its a bunch of jumbled garbage.

Fortunately, this compile step can be done right in iOS.

Install the toolchain

First step is to install Coolstar's toolchain. If you're on iOS 7-9 you can just go into Cydia and search iOS toolchain and install that. But if you're on iOS 10 its a little more complicated than that because iOS 10 doesn't have stashing. All of the stuff gets put into the system partition. Which is bad because the system partition only has like 60MB of space and the toolchain takes up 275MB. I will post a workaround at some point. So yeah, if you're on iOS 10 you're screwed (for now), unless if you know how to manually stash. I am aware that Coolstar has a tool to automate a lot of this, but I do not recommend it. It is unstable, and he has recently dropped support.

Download an iPhone SDK

The next step is to download an iPhone SDK. The legit way is to download Xcode and extract it from there, but nobody's got time for that. Just download this zip, unzip it, and copy iPhoneOS9.3.sdk (yes, iOS 9.3, it's old but it will work) to your phone. I recommend putting it in the /var/ folder.

Making sure it works

That's pretty much it. If you want to test it, make a file called test.c and put this code in it:

#include <stdio.h>

int main(int argc, char *argv[])
{
    printf("it worked\n");
    return 0;
}

Then run these commands:

clang -isysroot /var/iPhoneOS9.3.sdk -arch armv7 -arch arm64 test.c
ldid -S a.out
./a.out

If everything worked then it'll say it worked in the console.

Hope this helped


Precisionxt

Thanks for the tutorial, maybe this will mean more help with the EQE app.