How to assign a new provisioning profile to the ipa file
What we can do in the situation when we need to assign a new provisioning profile to the old .ipa file without the need for the creation of a new one with the Xcode or from the command line?
We can:
- use the Fastlane resign tool or
- some script.
Today we will quickly go through the procedure using a script. We will use the script from Daniel Torrecillas). Thank you, Daniel.
We will expect we have an old ipa file to resign, a new provisioning profile, and the downloaded shell script. Don't rename it otherwise we need to use its new name instead of its current one.
1. Prepare a work directory
There will be a place for temporary files and the resigned ipa file. We can delete it after the successful end of the process.
2. Add files to the directory
Add files to the directory:
- the old ipa file,
- the new provisioning profile (.mobileprovision) and
- the downloaded shell script.

3. Add permissions to the script
Open the terminal in the directory and add permissions to the script in the terminal using the command:
chmod 755 resign-ios-app
Without this step, the script won't be executed.
4. Call the script
We can call the script using 3 or 4 parameters:
- the path of the old ipa file (old.ipa file),
- the path of the new provisioning profile (newProvisioningProfile.mobileprovision file),
- the name of the distribution certificate in the Keychain,
- the new bundle identifier. This parameter is optional and we won't use it in our example. Without this parameter is the current bundle identifier used.
./resign-ios-app 'old.ipa' 'newProvisioningProfile.mobileprovision' 'Apple Distribution: TeamName (teamID)'

Result
As a result, you get the resigned.ipa file into the directory where the shell script is (it is your working directory from step 1).

Now you can use the resigned ipa file and delete your work directory from step 1.
Note: The script creates several subdirectories and plists. They are important only for the script itself. You can delete them.
If you find any inaccuracies or problems in this article please tweet at me @Carrione4. Thank you for your help.