Posts tagged ‘Xcode’

iOS Mobileprovision expired? No problem! – Update

Last year, I wrote a quick article on how to re-sign an IPA, replacing an expired mobile provisioning profile.

It turns out that with the latest versions of Xcode, the code provided doesn’t work anymore. It’s requiring an extra step now.

Let’s take a look a the code that was posted last year:

unzip app.ipa
rm -rf Payload/MyApp.app/_CodeSignature/
cp ~/Downloads/MyProfile.mobileprovision Payload/MyApp.app/embedded.mobileprovision
codesign -f -s “iPhone Distribution: Name Of My Certificate” –resource-rules Payload/MyApp.app/ResourceRules.plist Payload/MyApp.app
zip -qr app-resigned.ipa Payload/

The step missing is right before the codesign command.

The new Xcode requires you to provide an entitlements file that describes the app before you codesign. Here’s what the Plist file looks like:

<?xml version="1.0" encoding="UTF-8"?>
<!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>
	<false/>
	<key>application-identifier</key>
	<string>TEAMID.BUNDLE-IDENTIFIER</string>
</dict>
</plist>

After replacing the TEAMID and the BUNDLE-IDENTIFIER placeholders with what’s provided in your mobileprovision file. To see what is in the mobileprovision file, simply run this command:

security cms -D -i <mobileprovision file here>

You should see a block under &lt;Entitlements&gt; with the application-identifier you need to add to your own Entitlements.plist file.

Once you’re done editing your Entitlements file, run the codesign command like this:

codesign -f –entitlements “Entitlements.plist” -s “iPhone Distribution: Name Of My Certificate”¬†Payload/MyApp.app

PLEASE NOTE: You need to NOT include this Entitlements.plist file in your Payload directory. This is used for code signing ONLY.

Here’s the full new set of commands to run:

security cms -D -i <mobileprovision file here>
<Modify your Entilements.plist file here>
<Save file as Entitlements.plist>

unzip app.ipa
rm -rf Payload/MyApp.app/_CodeSignature/
cp ~/Downloads/MyProfile.mobileprovision Payload/MyApp.app/embedded.mobileprovision
codesign -f –entitlements “Entitlements.plist” -s “iPhone Distribution: Name Of My Certificate”¬†Payload/MyApp.app
zip -qr app-resigned.ipa Payload/

Enjoy!

Simon

iOS Mobileprovision expired? No problem!

I ran across an issue with an app I had distributed with an enterprise distribution certificate. The problem is, after a year, the certificate expired.

What to do? Download the code again, recompile the app, make sure everything works with the latest iOS SDK, etc. I ran into multiple issues doing so as the application I needed to update the embedded provisioning profile where, because of changes in the iOS SDK, some of my code was simply not compatible anymore. It’s a legacy app and nobody wants to update that stuff, no time, no budget, etc.

Then, I came across this brilliant website that explained how to extract the app, inject a new mobile provisioning profile, resign the app and repackage everything. Here’s the code for it:

unzip app.ipa
rm -rf Payload/MyApp.app/_CodeSignature/
cp ~/Downloads/MyProfile.mobileprovision Payload/MyApp.app/embedded.mobileprovision
codesign -f -s “iPhone Distribution: Name Of My Certificate” –resource-rules Payload/MyApp.app/ResourceRules.plist Payload/MyApp.app
zip -qr app-resigned.ipa Payload/

Genius! Worked like a charm and saved me the headache of re-compiling everything.

Enjoy!

Source: http://blog.favo.org/post/21905923260/how-to-manually-re-sign-an-ipa-with-a-new-provisioning