Jailbroken development with iOS 5.0.1 and XCode 4.2

Comment
There is a lot of scattered information out there, so I am going to confirm this is going to work only for the specific configuration given below.

Configuration details

XCode version = 4.2
(BUILD 4D199 - But any build of XCode 4.2 should work)

MAC OS X = 10.7.2

iOS 5.0.1 (9A405)
Jailbroken iPod Touch 4th Gen (and has Cydia on it)

How to start developing with XCode without iPhone developer account ?

First is to disable CODESIGN (read code-sign).

Make a copy of this file on Desktop (Because finder won't allow you to edit in the same folder)
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/SDKSettings.plist


Open that file in TextEdit and change the following values from YES to NO. So it looks like below

<key>CODE_SIGNING_REQUIRED</key>
<string>NO</string>
<key>ENTITLEMENTS_REQUIRED</key>
<string>NO</string>

Now restart XCode and set Code Signing Identity to Don't Code Sign


Now you should be able to select your device from the list and install your code/app.

But still you won't be able to debug, how to enable that ?

1) Select your target from Targets list, on the right side choose "Build phases"
2) Now on the bottom right you have a button called "Add Bhild Phase". Click that
3) Now select "Add Run Script"
4) Now copy paste the follow code in the run script box.


export CODESIGN_ALLOCATE=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate
if [ "${PLATFORM_NAME}" == "iphoneos" ]; then/Developer/iphoneentitlements41/gen_entitlements.py "my.company.${PROJECT_NAME}" "${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/${PROJECT_NAME}.xcent";codesign -f -s "iPhone Developer" --entitlements "${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/${PROJECT_NAME}.xcent" "${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/"
fi

Note : The above code is taken from Alex Whittemore's Blog.
But there "/Developer/iphoneentitlements401/gen_entitlements.py" was used instead of "/Developer/iphoneentitlements41/gen_entitlements.py". I had to manually check that path and found that there was no 'iphoneentitlements401' folder on my machine. I changed it and it worked. Now I am able to debug also !

Let me know if this worked, so it will help others from wasting time as well.
If you ran into any problem let me know as well! I will try my best to help you.