跳过内容

MASTG-TECH-0092: 签名 IPA 文件

要在非越狱设备上安装 IPA 文件,它需要具有有效的签名。 在越狱设备上,安装 AppSync Unified 后,则不需要此操作。

首先,你需要获取一个开发者配置文件和证书,如 获取开发者配置文件 中所述。

警告

如果你有一个普通的 Apple 帐户,你只能使用修改后的(唯一的)Bundle 标识符签署 IPA。 如果你有一个开发者帐户,你可以使用原始 Bundle 标识符进行签名。

可以使用 ios-app-signer fastlane Sideloadly codesign 完成签名过程。

使用 fastlane

创建一个 fastlane 目录,并创建一个 Fastfile 文件,如 重签名 文档中所述。 将 Fastfile 和你的 IPA 文件都放入 fastlane 目录中。

示例

lane :resignipa do
  resign(
    ipa: "./filename.ipa",
    signing_identity: "Apple Development: [email protected] (LVGBSLUQB4)",
    provisioning_profile: "./embedded.mobileprovision",
  )
end

之后,执行 fastlane resignipa 命令。

$ fastlane resignipa
[] 🚀 
[15:21:51]: Get started using a Gemfile for fastlane https://docs.fastlane.tools/getting-started/ios/setup/#use-a-gemfile
[15:21:52]: Driving the lane 'resignipa' 🚀
[15:21:52]: --------------------
[15:21:52]: --- Step: resign ---
[15:21:52]: --------------------
...
[15:22:03]: Successfully signed /test.ipa!
[15:22:03]: Successfully re-signed .ipa 🔏.

+-----------------------------+
|      fastlane summary       |
+------+--------+-------------+
| Step | Action | Time (in s) |
+------+--------+-------------+
| 1    | resign | 11          |
+------+--------+-------------+

[15:22:03]: fastlane.tools finished successfully 🎉

一旦设置好,你所需要做的就是更改 Fastfile 中要重签名的 IPA 文件的路径,然后再次运行该命令。

更多信息可以在官方文档中找到:“使用 fastlane resign 对现有 ipa 文件进行代码签名”

警告

默认情况下,fastlane 始终使用给定配置文件中的 Bundle 标识符,无论是对于普通 Apple 帐户还是开发者帐户。 如果你有一个开发者帐户,你可以通过直接使用 Fastlane 打包的 resign.sh 脚本并指定 --bundle-id 属性来指定所需的 Bundle 标识符

$ /opt/homebrew/Cellar/fastlane/2.226.0/libexec/gems/fastlane-2.226.0/sigh/lib/assets/resign.sh /Users/MAS/uncrackable1.ipa <CERTIFICATE> -p /Users/MAS/embedded.mobileprovision /Users/MAS/signed.ipa -v --bundle-id "org.mas.myapp"

Specified provisioning profile: '/Users/MAS/embedded.mobileprovision'
Original file: '/Users/MAS/uncrackable1.ipa'
Certificate: '<CERTIFICATE>'
Specified bundle identifier: 'org.mas.myapp'
Output file name: '/Users/MAS/signed.ipa'
Current bundle identifier is: 'org.mas.testapp'
New bundle identifier will be: 'org.mas.myapp'
Validating the new provisioning profile: /Users/MAS/embedded.mobileprovision
Profile app identifier prefix is '6FZT6QZ6X3'
Profile team identifier is '6FZT6QZ6X3'
Updating the bundle identifier from 'org.mas.testapp' to 'org.mas.myapp'
Fixing nested app and extension references
Extracting entitlements from provisioning profile
Resigning application using certificate: '<CERTIFICATE>'
and entitlements from provisioning profile: /Users/MAS/embedded.mobileprovision
_floatsignTemp/Payload/UnCrackable Level 1.app: replacing existing signature
_floatsignTemp/Payload/UnCrackable Level 1.app: signed app bundle with Mach-O universal (armv7 arm64) [org.mas.myapp]
Repackaging as /Users/MAS/signed.ipa

使用 Sideloadly

Sideloadly 可以负责获取你的应用程序的有效证书,但无法简单地就地签名现有 IPA 文件。 Sideloadly 将对给定的 IPA 文件进行签名,并将其直接安装在连接的设备上。 当使用普通的 Apple 帐户时,Sideloadly 会通过附加你的团队标识符来修改原始包名称(例如,sg.vp.UnCrackable1 变为 sg.vp.UnCrackable1.QH868V5764