Skip to content

Instantly share code, notes, and snippets.

@upbit
Last active October 8, 2018 10:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save upbit/a88ddbd191c42f741900 to your computer and use it in GitHub Desktop.
Save upbit/a88ddbd191c42f741900 to your computer and use it in GitHub Desktop.
XCode codesign on jailbreak devices
export CODESIGN_ALLOCATE=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate
if [ "${PLATFORM_NAME}" == "iphoneos" ] || [ "${PLATFORM_NAME}" == "ipados" ]; then
/Applications/Xcode.app/Contents/Developer/iphoneentitlements/gen_entitlements.py "com.ios.${PROJECT_NAME}" "${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/${PROJECT_NAME}.xcent";
codesign -f -s "iPhone Developer" --entitlements "${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/${PROJECT_NAME}.xcent" "${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/"
fi
# Crack Xcode codesign
# SDKSettings.plist
SDK_ROOT="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk"
#sudo cp ${SDK_ROOT}/SDKSettings.plist ${SDK_ROOT}/SDKSettings.plist.bak
cp -f ${SDK_ROOT}/SDKSettings.plist ./sdk.plist
plutil -convert json sdk.plist
sed -e 's/"CODE_SIGNING_REQUIRED":"YES"/"CODE_SIGNING_REQUIRED":"NO"/g' sdk.plist > tmp.plist
sed -e 's/"ENTITLEMENTS_REQUIRED":"YES"/"ENTITLEMENTS_REQUIRED":"NO"/g' tmp.plist > SDKSettings.plist
plutil -convert binary1 SDKSettings.plist
rm -f sdk.plist tmp.plist
sudo cp -fv SDKSettings.plist ${SDK_ROOT}/SDKSettings.plist
plutil -p ${SDK_ROOT}/SDKSettings.plist | grep -A1 "ENTITLEMENTS_REQUIRED"
# Info.plist
PLATFORM_ROOT="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform"
#sudo cp ${PLATFORM_ROOT}/Info.plist ${PLATFORM_ROOT}/Info.plist.bak
cp -f ${PLATFORM_ROOT}/Info.plist ./itmp.plist
plutil -convert json itmp.plist
sed -e 's/XCiPhoneOSCodeSignContext/XCCodeSignContext/g' itmp.plist > tmp.plist
sed -e 's/"Version":"8.3",/"Version":"8.3","PROVISIONING_PROFILE_ALLOWED":"NO","PROVISIONING_PROFILE_REQUIRED":"NO",/g' tmp.plist > Info.plist
plutil -convert binary1 Info.plist
rm -f itmp.plist tmp.plist
sudo cp -fv Info.plist ${PLATFORM_ROOT}/Info.plist
plutil -p ${PLATFORM_ROOT}/Info.plist | grep "XCCodeSignContext"
# cleanup
rm -f SDKSettings.plist Info.plist
# setup gen_entitlements.py
ENTITLEMENT_PATH="/Applications/Xcode.app/Contents/Developer/iphoneentitlements"
sudo mkdir ${ENTITLEMENT_PATH}
cd ${ENTITLEMENT_PATH}
sudo curl -O http://www.alexwhittemore.com/iphone/gen_entitlements.txt
sudo mv gen_entitlements.txt gen_entitlements.py
sudo chmod 777 gen_entitlements.py
ls -l ${ENTITLEMENT_PATH}/gen_entitlements.py

修改XCode配置文件

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/

SDKSettings.plist

> CODE_SIGNING_REQUIRED: NO
> ENTITLEMENTS_REQUIRED: NO

Info.plist

+ PROVISIONING_PROFILE_ALLOWED: NO
+ PROVISIONING_PROFILE_REQUIRED: NO

> XCiPhoneOSCodeSignContext -> XCCodeSignContext

gen_entitlements.py

mkdir /Applications/Xcode.app/Contents/Developer/iphoneentitlements
cd /Applications/Xcode.app/Contents/Developer/iphoneentitlements

sudo curl -O http://www.alexwhittemore.com/iphone/gen_entitlements.txt
sudo mv gen_entitlements.txt gen_entitlements.py
sudo chmod 777 gen_entitlements.py
@upbit
Copy link
Author

upbit commented Apr 11, 2015

Run ./crack_codesign.sh for auto crack Xcode 6.x+

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment