-
Notifications
You must be signed in to change notification settings - Fork 17
/
resign.sh
64 lines (53 loc) · 1.55 KB
/
resign.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/zsh
# https://fotidim.com/carplay-apps-without-entitlements-in-an-actual-car-37a708758262
if [ -z "$1" ]
then
echo "$0 [ipa/app file to enable carplay on]"
exit 1
fi
mkdir temp
cd temp
if [[ $1 == *.app ]]; then
echo "Generating ipa structure"
mkdir Payload
cp -r ../$1 Payload/
else
echo "Extracting ipa"
unzip -q ../$1
fi
app=$(ls Payload/)
echo "Found $app"
if [ -f "Payload/$app/embedded.mobileprovision" ]; then
echo "Merging entitlements"
security cms -D -i "Payload/$app/embedded.mobileprovision" > provision.plist
/usr/libexec/PlistBuddy -x -c 'Print:Entitlements' provision.plist > entitlements.plist
/usr/libexec/PlistBuddy -x -c "Merge ../CarPlay.entitlements" entitlements.plist
echo "Signing with CarPlay entitlement"
uname=$(id -un)
codesign -d --entitlements entitlements.plist -f -s "Apple Development: $uname" Payload/$app
signed=$(codesign -d --entitlements - "Payload/$app" | grep -c "com.apple.developer.carplay-maps")
if [ $signed > 0 ]; then
echo "Signed succesfully!"
zip -r "$app.ipa" Payload -q
cp "$app.ipa" ../
else
echo "Failed to sign!"
exit 1
fi
else
echo "Generating entitlement"
uname=$(id -un)
codesign -d --entitlements ../CarPlay.entitlements -f -s "Apple Development: $uname" Payload/$app
signed=$(codesign -d --entitlements - "Payload/$app" | grep -c "com.apple.developer.carplay-maps")
if [ $signed > 0 ]; then
echo "Signed succesfully!"
zip -r "$app.ipa" Payload -q
cp "$app.ipa" ../
else
echo "Failed to sign!"
exit 1
fi
fi
cd ..
echo "Cleaning temporary files"
rm -rf temp