If you want to compile a shared library for iOS, particularly for Mobile Substrate, here are some easy enough steps to do it all via CLI.

Setup

You need Theos installed, normally into /opt/theos. Follow the getting started guide

Then create a new Theo project. The following is named SampleCrack

user@myhost> $THEOS/bin/nic.pl
NIC 2.0 - New Instance Creator
------------------------------
[1.] iphone/application
[2.] iphone/library
[3.] iphone/preference_bundle
[4.] iphone/tool
[5.] iphone/tweak
Choose a Template (required): 2
Project Name (required): SampleCrack
Package Name [com.yourcompany.samplecrack]:
Author/Maintainer Name [c0ffee]: 
Instantiating iphone/library in samplecrack/...
Done.

Then look about

user@myhost> cd samplecrack
user@myhost> ls
./working/samplecrack
Makefile       SampleCrack.mm control        theos

We are going to be using captain hook. Check it out

user@myhost> git clone
git://github.com/rpetrich/CaptainHook.git

Write

Then let’s write the code, make sure you mod it to your liking, sadly there are no docs for CaptainHook.

user@myhost> cat > SampleCrack.h
#import <Foundation/Foundation.h>

@interface SampleCrack : NSObject
@end
user@myhost> cat > SampleCrack.mm
#import "SampleCrack.h"
#import "Foundation/Foundation.h"
#import "CaptainHook/CaptainHook.h"
#include "notify.h"

@implementation SampleCrack
-(id)init
{
    if ((self = [super init])){} return self;
}
@end

@class SampleAppViewController;
CHDeclareClass(SampleAppViewController);
CHOptimizedMethod(0, self, _Bool, SampleAppViewController, isDeviceRooted)
{
    NSLog(@"####### isJailBroken hooked"); // Logging saves lives
    return true;
}

CHConstructor {
    @autoreleasepool {
        CHLoadLateClass(SampleAppViewController);
        CHHook(0, SampleAppViewController, isDeviceRooted); // register hook
    }
}

Build

Then we compile:

user@myhost> make

If you get an error that looks anything like the following:

./working/samplecrack/theos/include/IOSurface/IOSurface.h:20:10:
fatal error: 'IOSurface/IOSurfaceAPI.h' file not found
#include <IOSurface/IOSurfaceAPI.h>

Then try including the IOSurfaceAPI.h in, I had to do this on lion.

> cp
/System/Library/Frameworks/IOSurface.framework/Headers/IOSurfaceAPI.h
./theos/include/IOSurface/

You will probably need to comment out the following lines also:

    /* This call lets you get an xpcobject_t that holds
a reference to the IOSurface.
    Note: Any live XPC objects created from an IOSurfaceRef implicity increase
the IOSurface's global use
    count by one until the object is destroyed. */
    // xpc_object_t IOSurfaceCreateXPCObject(IOSurfaceRef aSurface)
    // IOSFC_AVAILABLE_STARTING(_MAC_10_7, __IPHONE_NA);

    /* This call lets you take an xpcobject_t created via IOSurfaceCreatePort()
and recreate an IOSurfaceRef from it. */
    // IOSurfaceRef IOSurfaceLookupFromXPCObject(xpc_object_t xobj)
    // IOSFC_AVAILABLE_STARTING(_MAC_10_7, __IPHONE_NA);

See this stack overflow post if you want more detail.

You are also going to need a copy of ldid. If you have ports, try there. Brew doesn’t seem to hold a copy (They gave up on it because it fails with clang? Use llvm g++). If those fail check try making it yourself:

git clone git://git.saurik.com/ldid.git
cd ldid
git submodule update --init
./make.sh
cp -f ./ldid $THEOS/bin/ldid

Make sure you drop it into $THEOS/bin/ldid

scp ./obj/SampleCrack.dylib
root@iphone:/Library/MobileSubstrate/
ssh root@iphone
root@iphone's password: 
iphone:~ root# 
ldid -S SampleCrack.ldid

Now you’ve got the dependencies, make it

user@myhost> export SDKVERSION=7.0
user@myhost> make

And you’ve got yourself a nice library

> file obj/SampleCrack.dylib
~/Documents/Customer/Documents/Elavon/working/samplecrack
obj/SampleCrack.dylib: Mach-O universal binary with 2 architectures: [arm_v7:
Mach-O arm_v7 dynamically linked shared library] [arm subarchitecture=11:
Mach-O arm subarchitecture=11 dynamically linked shared library]