Tag Archives: development

Use Xcode 4.3.2 to build and run app on jailbroken iDevices

If you have jailbroken iDevices like me and no Apple Developer Certificates (quite expensive and I did not have finish my apps :p)

It is very easy to configure Xcode to do so.

Simply follow these steps :

First of all, we need a certificate.
Open the Keychain app from the LaunchPad > Utilities > Keychain Access

From the menus, choose “Certificate Assistant” > create a certificate
From the window, choose Certificate Type => Code Signing
and from the Text Input above, choose a name for our certificate such as JailbreakTests (You need to remember the name 😉 )

Now open a shell and type the following command

cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/

edit the Info.plist with nano

sudo nano Info.plist

and replace every XCiPhoneOSCodeSignContext => XCCodeSignContext

The third part is to remove code signing requirement :
from the current directory change to ./Developer/SDKs/iPhoneOSX.Y.sdk with X.Y egal to 5.1 for example

cd Developer/SDKs/iPhoneOS5.1.sdk/

and then

sudo nano SDKSettings.plist

and replace …_REQUIRED > NO to YES (SIGN_REQUIRED, etc…)

Now, we have to binary patch the
App :

cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/PrivatePlugIns

cd iPhoneOS\ Build\ System\ Support.xcplugin/Contents/MacOS/
sudo nano create.sh

copy and paste the following code in it :

dd if=iPhoneOS\ Build\ System\ Support of=working bs=500 count=255
printf "\xc3\x26\x00\x00" >> working
/bin/mv -n iPhoneOS\ Build\ System\ Support iPhoneOS\ Build\ System\ Support.original
/bin/mv working iPhoneOS\ Build\ System\ Support
chmod a+x iPhoneOS\ Build\ System\ Support

now press ctrl+o and ctrl+x
and use

sudo chmod +x create.sh
sudo ./create.sh

You will se something like
55+1 … in
55+1 … out
27712 bytes transfered

Restart Xcode if it was open, if not, just launch it !

Open your project and change the build configuration from every Code Signing to “Don’t Code Sign”
This step will make Xcode not code signing the code

Now, we will code sign ourself the code, to enable it we execute this code :

mkdir -p /Developer/iphoneentitlements51
cd /Developer/iphoneentitlements51
curl -O http://www.alexwhittemore.com/iphone/gen_entitlements.txt
mv gen_entitlements.txt gen_entitlements.py
chmod 777 gen_entitlements.py

and now, in the project, on the target add a new custom build phase to run script:
and copy/paste this code and replace iPhone Developer to the name you choose when you made your certificate:

export CODESIGN_ALLOCATE=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate
if [ "${PLATFORM_NAME}" == "iphoneos" ]; then
/Developer/iphoneentitlements401/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}/"

This code will auto sign the application

If your iDevices was not configure to do development, you need to open the Organizer and select your iDevice. Then choose “Use for development”

That’s it, you can now choose the iDevice instead of the emulators

Source : http://stackoverflow.com/questions/246422/how-can-i-deploy-an-iphone-application-from-xcode-to-a-real-iphone-device