iOS modify ipa and re-sign the package

1. Unzip the ipa package

In the cmd terminal, cd to the directory where ipa is located, and enter the following command:

#
# test.ipa:需要解压的ipa文件
#
unzip -q test.ipa

After decompression, a Payload folder is generated in the current directory, right click on the corresponding app file -> show package content, and view the app content

2. Modify ipa information

Now you can modify the information in the app. To modify the application name, you only need to modify the info.plist . Find CFBundleDisplayName and CFBundleName in the info.plist file, modify the corresponding value and save it. 

To modify the version number, you only need to modify the values ​​corresponding to CFBundleShortVersionString and CFBundleVersion in the  info.plist file

To modify the package name, you only need to modify the value corresponding to CFBundleIdentifier in the info.plist file

Modifying the application icon only needs to replace the corresponding icon file

3. Re-sign and package ipa

Enter the following command in the terminal to remove the old signature information

rm -r -f Payload/test.app/_CodeSignature

Put the signed configuration file developer.mobileprovision into the current folder, and use the following command to generate the plist file:

#
# developer.mobileprovision:签名配置文件
# ProvisioningProfile.plist: 解码生成的plist文件
#
security cms -D -i developer.mobileprovision > ProvisioningProfile.plist

Extract the generated entitlements related plist file from the generated plist file using the following command: Entitlements.plist

/usr/libexec/PlistBuddy -x -c 'Print Entitlements' ProvisioningProfile.plist > Entitlements.plist

Enter the command to copy and rename the signature configuration file developer.mobileprovision into the corresponding app package

#
# developer.mobileprovision: 签名配置文件
#
cp developer.mobileprovision Payload/test.app/embedded.mobileprovision

If there are dependent libraries and frameworks, use the following command to sign the dependent libraries and frameworks

#
# distributionCertificate:签名使用钥匙串中证书的名称
#
if [[ -e Payload/test.app/Frameworks ]]; then
  cd Payload/test.app/Frameworks
  echo "Resigning embedded Swift libraries..."
  swiftLibraries=$(find . -name '*dylib')
  SDK_PATH="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/"
  for dylib in $swiftLibraries; do
    codesign -f -s distributionCertificate "$dylib"
  done
  frameworks=$(find . -name '*framework')
  echo "Resigning embedded frameworks..."
  for framework in $frameworks; do
    codesign -f -s "distributionCertificate "$framework"
  done
  cd ../../..
fi

Use the following command to sign the modified app package and repackage it into a new ipa

#
# distributionCertificate:签名使用钥匙串中证书的名称
#
codesign -f -s distributionCertificate --entitlements Entitlements.plist Payload/test.app

#
# modify.ipa: 新生成的ipa文件
#
zip -q -r modify.ipa Payload SwiftSupport Symbols

The final generated modify.ipa is the ipa file we will use in the end

Guess you like

Origin blog.csdn.net/jxfcwys/article/details/126937538