Xcode: Difference between revisions

From iPhone Development Wiki
(→‎Allowing apps with invalid signatures to be installed: - It's much easier to use a prepatched version of installd, rather than trying to compile a patched version yourself.)
(I understand the ease of use, but I can't condone linking to even a search for a patched installd. I'm sorry.)
Line 11: Line 11:
* '''1.''' Create a self-signed code-signing certificate on the “login” (default) keychain using Keychain Access<ref>Procedures can be found in http://developer.apple.com/mac/library/documentation/Security/Conceptual/CodeSigningGuide/Procedures/Procedures.html</ref>.
* '''1.''' Create a self-signed code-signing certificate on the “login” (default) keychain using Keychain Access<ref>Procedures can be found in http://developer.apple.com/mac/library/documentation/Security/Conceptual/CodeSigningGuide/Procedures/Procedures.html</ref>.
* '''2.''' Open <tt>/Developer/Platforms/iPhoneOS.platform/Info.plist</tt>
* '''2.''' Open <tt>/Developer/Platforms/iPhoneOS.platform/Info.plist</tt>
* '''3.''' Replace all occurrences of <tt>XCiPhoneOSCodeSignContext</tt> by <tt>XCCodeSignContext</tt>. There are three of them (XCode Version3.2.4).
* '''3.''' Replace all occurrences of <tt>XCiPhoneOSCodeSignContext</tt> by <tt>XCCodeSignContext</tt>. There should be two of them, one around line 46 and another around line 79.
* '''4.''' Save the file and restart Xcode.
* '''4.''' Save the file and restart Xcode.


Line 44: Line 44:
=== Allowing apps with invalid signatures to be installed ===
=== Allowing apps with invalid signatures to be installed ===
These steps allow you to install an unsigned app to the device. Embarrassedly, like all other MobileInstallation/installd patches, this allows pirated apps to be installed via iTunes as well.
These steps allow you to install an unsigned app to the device. Embarrassedly, like all other MobileInstallation/installd patches, this allows pirated apps to be installed via iTunes as well.
You can either download a [http://www.google.com/search?q=patched+installd prepatched version of installd] by adding alternative repositories to Cydia, or patch it yourself as the following instructions demonstrate.


* '''10.''' Copy <tt>/usr/libexec/installd</tt> from your device to your Mac.
* '''10.''' Copy <tt>/usr/libexec/installd</tt> from your device to your Mac.

Revision as of 00:35, 21 September 2010

Xcode is the IDE endorsed by Apple for iPhoneOS development. The latest version 3.2.1. It comes with the official iPhone SDK.

Developing without Provisioning Profile

To develop for the devices one should first obtain a provisioning profile by joining the iPhone Developer Program (which costs $99). However, some simple tricks can be used to make Xcode compile and debug on jailbroken devices without provisioning profiles.

These steps are only tested for Xcode 3.2.x and iPhone SDK 3.x. If for some reason you are stuck with Xcode 3.1.x, try [1].

Compiling

Performing these steps allows you to use Xcode to compile any applications and deploy it yourself.

  • 1. Create a self-signed code-signing certificate on the “login” (default) keychain using Keychain Access[1].
  • 2. Open /Developer/Platforms/iPhoneOS.platform/Info.plist
  • 3. Replace all occurrences of XCiPhoneOSCodeSignContext by XCCodeSignContext. There should be two of them, one around line 46 and another around line 79.
  • 4. Save the file and restart Xcode.

If you upgrade the iPhone SDK, you need to perform steps 2 – 4 again.

Replacing codesign with ldid

These steps are necessary for debugging, since the entitlement can no longer be inserted by performing steps 1 – 4. To actually debug your app, make sure you have add -gta to Other Code Signing Flags of your target.

  • 5. Make sure you have ldid on your Mac[2]. Place a copy in /usr/local/bin.
  • 6. Create the file /usr/local/bin/ldid2. Make it executable. Fill it with:
#!/bin/sh

hasGTA=`expr "$*" : '.* -gta .*'`;
objpath=${!#}/`expr ${!#} : '.*/\([^/]\{1,\}\)\.app$'`;

if [[ $hasGTA == 0 ]]; then
 /usr/local/bin/ldid -S $objpath;
else
 TF=`mktemp -t x`;
 echo "<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\"><plist version=\"1.0\"><dict><key>get-task-allow</key><true/></dict></plist>" > $TF;
 /usr/local/bin/ldid -S$TF $objpath;
 rm $TF;
fi;
  • 7. Open /Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Plug-ins/iPhoneOS Build System Support.xcplugin/Contents/Resources/iPhoneCodeSign.xcspec
  • 8. Replace the line saying CommandLine = "/usr/bin/codesign" with CommandLine = "/usr/local/bin/ldid2". It should be around line 12.
  • 9. Save the file and restart Xcode.

If you upgrade the iPhone SDK, you need to perform steps 8 – 9 again.

Allowing apps with invalid signatures to be installed

These steps allow you to install an unsigned app to the device. Embarrassedly, like all other MobileInstallation/installd patches, this allows pirated apps to be installed via iTunes as well.

  • 10. Copy /usr/libexec/installd from your device to your Mac.
  • 11. Run this:
install_name_tool -change /usr/lib/libmis.dylib /usr/lib/libmiss.dylib installd
ldid -S installd
  • 12. Create a file named libmiss.c, and enter these into the file:
extern int MISValidateSignature() { return 0; }
  • 13. Compile libmiss.c to libmiss.dylib with gcc targeting iPhone:
# NOTE: Must provide a valid path for -isysroot.

/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2                  \
  -arch armv6                                                                     \
  -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.sdk \
  -dynamiclib                                                                     \
  -install_name /usr/lib/libmiss.dylib                                            \
  -current_version 1                                                              \
  -compatibility_version 1                                                        \
  -Wl,-reexport-lmis                                                              \
  -flat_namespace                                                                 \
  -o libmiss.dylib                                                                \
  libmiss.c
ldid -S libmiss.dylib
  • 14. Copy the new installd to the device's /usr/libexec, and the libmiss.dylib to the device's /usr/lib.

If you upgrade the firmware, you need to do step 14 again.

References