Q:

Resign iOS app without specifying identity

I am currently developing an app in Xamarin Studio, where I would like to modify the build info.plist via a script. Xamarin Studio unfortunately lacks a script build phase however, so my only option is really to run a script after the build, which of course breaks the signing.
Since different identities are used for different configurations I cannot make the identity static, and either way I'd really like to interfere with Xamarin as little as possible (I.E. be able to use the project settings etc).
Is there a way to resign the app using the identity it is currently signed with, via a shell script? 

A:

So I found a solution:
#!/usr/bin/env python

import sys
import subprocess
import re
import os

app_path = os.path.abspath(sys.argv[1])

signing_info = subprocess.Popen(['codesign', '--display', '--verbose=4', app_path], stdin=subprocess.PIPE, stderr=subprocess.STDOUT, stdout=subprocess.PIPE, close_fds=True).communicate()[0]

identity = re.search('Authority=(.*)', signing_info).group(1)

subprocess.call(['codesign', '--sign', identity, '--force', '--preserve-metadata=entitlements,resource-rules,requirements', '/Users/stefanfisk/Projekt/Tunaspot/Xamarin/App/Touch/bin/iPhone/Ad-Hoc/Touch.app'])

