Skip to content

Instantly share code, notes, and snippets.

@demonnico
Last active May 5, 2019 12:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save demonnico/8017146 to your computer and use it in GitHub Desktop.
Save demonnico/8017146 to your computer and use it in GitHub Desktop.
resign ipa file
#First of all, create a new plist file named 'channnel.plist' and refer into your project.
#Second, move codes below in 'didFinishLaunchingWithOptions'
#NSString * channelPath = [[NSBundle mainBundle] pathForResource:@"channel" ofType:@"plist"];
#NSDictionary*channelDic= [NSDictionary dictionaryWithContentsOfFile:channelPath];
#NSString * channelIdentify = [channelDic objectForKey:@"channel"];
#[MobClick startWithAppkey:UMENG_KEY reportPolicy:BATCH channelId:channelIdentify];
#last step, 'cd' into the folder where xxx.ipa is there.
#generally, it's the name of scheme
appName="xiaonimei"
#you can find it in system keychains, or xcode build setting.
certificate="iPhone Developer"
#the channels which you'll distribute to.
channel[0]="91helper"
channel[1]="pphelper"
channel[2]="tongbutui"
channel[3]="kuaiyong"
channel[4]="pphelper"
channel[5]="weiphone"
for((i=0;i<5;i++))
do
# unzip the IPA
unzip $appName.ipa
# delete old signature
rm -rf Payload/${appName}.app/_CodeSignature/
channelIdentify=${channel[$i]}
/usr/libexec/PlistBuddy -c "Set :channel $channelIdentify" Payload/${appName}.app/channel.plist
# copy new provisioning profile into the App
#cp ~/Downloads/embedded.mobileprovision Payload/xiaonimei.app/embedded.mobileprovision
# sign the App
codesign -f -s $certificate --resource-rules Payload/${appName}.app/ResourceRules.plist Payload/${appName}.app
# zip the contents into a new IPA file
zip -qr ${appName}_${channel[$i]}.ipa Payload/
# remove Payload group
rm -rf Payload/
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment