标签:
本文未经测试,初步看代码流程接近本人想法,留下作记录。
Intoduction
This code allow you to resign your own ipa assuming that you have:
1) a developer certificate issued by apple and added to your keychain
2) a mobileprovision fileThis code allow you to resign your app without using xcode or if you need to add a UDID for development distribution.
This code correctly signs ipas with Frameworks (.framework folders), Plugins (.appex folders), Applications (.app folders)
This code autoincludes entitlements with binaries extracting them from the provided mobileprovision file.
Usage
This code runs on mac osx
You should already have installed OSX Command Lines Tools
The code is a shell script
Step 1
Change the following variables inside the signall.sh script:
1
2
3
4
5
6
|
signscript="/path/to/sign.sh"
ipasourcefolder="path/to/ipas/source/folder"
ipadestfolder="/path/to/ipas/destinations/folder/"
developer1="iPhone Developer: xxxxx (xxxxx)"
mobileprovision1="/path/to/mobile/provision"
|
Step 2
1
2
3
|
make sure that ipasourcefolder and ipadestfolder are writable
run signall.sh via terminal
done
|
In your destination folder you will have all your ipas signed.
Source and Updates
https://bitbucket.org/xgiovio/ios-ipa-resign/src
Code
signall.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# !/bin/bash
signscript="/path/to/sign.sh"
ipasourcefolder="path/to/ipas/source/folder"
ipadestfolder="/path/to/ipas/destinations/folder/"
developer1="iPhone Developer: xxxxx (xxxxx)"
mobileprovision1="/path/to/mobile/provision"
cd $ipasourcefolder
find -d . -type f -name "*.ipa"> files.txt
while IFS=‘‘ read -r line || [[ -n "$line" ]]; do
filename=$(basename "$line" .ipa)
echo "Ipa: $filename"
#_dev1_______
output=$ipadestfolder$filename
output+="_signed_dev1.ipa"
"$signscript" "$line" "$developer1" "$mobileprovision1" "$output"
done < files.txt
rm files.txt
|
sign.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# !/bin/bash
SOURCEIPA="$1"
DEVELOPER="$2"
MOBILEPROV="$3"
TARGET="$4"
unzip -qo "$SOURCEIPA" -d extracted
APPLICATION=$(ls extracted/Payload/)
cp "$MOBILEPROV" "extracted/Payload/$APPLICATION/embedded.mobileprovision"
echo "Resigning with certificate: $DEVELOPER" >&2
find -d extracted \( -name "*.app" -o -name "*.appex" -o -name "*.framework" -o -name "*.dylib" \) > directories.txt
security cms -D -i "extracted/Payload/$APPLICATION/embedded.mobileprovision" > t_entitlements_full.plist
/usr/libexec/PlistBuddy -x -c ‘Print:Entitlements‘ t_entitlements_full.plist > t_entitlements.plist
#/usr/libexec/PlistBuddy -c ‘Print:application-identifier‘ t_entitlements.plist > t_entitlements_application-identifier #save developer application-identifier to file
#/usr/libexec/PlistBuddy -c ‘Print:com.apple.developer.team-identifier‘ t_entitlements.plist > t_entitlements_com.apple.developer.team-identifier #save com.apple.developer.team-identifier application-identifier to file
while IFS=‘‘ read -r line || [[ -n "$line" ]]; do
#/usr/bin/codesign -d --entitlements :- "$line" > t_entitlements_original.plist #save original entitlements from the app
#/usr/libexec/PlistBuddy -x -c ‘Import application-identifier t_entitlements_application-identifier‘ t_entitlements_original.plist #overwrite application-identifier
#/usr/libexec/PlistBuddy -x -c ‘Import com.apple.developer.team-identifier t_entitlements_com.apple.developer.team-identifier‘ t_entitlements_original.plist #overwrite com.apple.developer.team-identifier
/usr/bin/codesign --continue -f -s "$DEVELOPER" --entitlements "t_entitlements.plist" "$line"
done < directories.txt
echo "Creating the Signed IPA"
cd extracted
zip -qry ../extracted.ipa *
cd ..
mv extracted.ipa "$TARGET"
rm -rf "extracted"
rm directories.txt
rm t_entitlements.plist
rm t_entitlements_full.plist
#rm t_entitlements_original.plist
#rm t_entitlements_application-identifier
#rm t_entitlements_com.apple.developer.team-identifier
|
标签:
原文地址:http://www.cnblogs.com/yuanxiaoping_21cn_com/p/5810984.html