Tutorial: How to create a MobileSubstrate plugin

First make sure you have XCode setup to build libraries.

Then follow the tutorial for making a library except name your project MobileSubstrateSample.

Now add a file called Tweak.mm to the Classes group and delete all the text in it and make it only contain the following:

extern "C" void TweakInitialize() {
    NSLog(@"Tweak has been initialized...");
Now set the initialize routine to _TweakInitialize in the project settings.

Build the project and SFTP the MobileSubstrateSample.dylib to your iPhone. The directory is: /Library/MobileSubstrate/DynamicLibraries/

Use Cydia to install the ldid utility.

SSH into the phone and cd to /Library/MobileSubstrate/DynamicLibraries/

ldid - S MobileSubstrateSample.dylib
Now run Weather and open up the Organizer in Xcode to look at the console output and see if it says "Tweak has been initialized" as it is in the image below.

When you make a modification, build and SFTP a new version of the dylib to the iPhone, you need to first delete the existing one then copy the new one on, then use lidid. Otherwise you will see the "Killed" message and ldid won't work.