ios 如何重新签署ipa文件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5160863/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 19:04:48  来源:igfitidea点击:

How to re-sign the ipa file?

iosios-provisioningipa

提问by Johnny

How do I sign the .ipa file with a provisioning profile after I generate an IPA like the following with a different provision profile? I would like to sign the IPA with an ad-hoc provisioning profile for beta testing, and then re-sign the exact IPA with an app submission provisioning profile for the app store.

在使用不同的配置文件生成如下 IPA 后,如何使用配置文件对 .ipa 文件进行签名?我想使用临时配置文件签署 IPA 以进行 Beta 测试,然后使用应用程序商店的应用程序提交配置文件重新签署确切的 IPA。

/usr/bin/xcrun -sdk iphoneos PackageApplication -v "${RELEASE_BUILDDIR}/${APPLICATION_NAME}.app" -o "${BUILD_HISTORY_DIR}/${APPLICATION_NAME}.ipa" --sign "${DEVELOPER_NAME}" --embed "${PROVISONING_PROFILE}"

回答by Bruno Bronosky

It's really easy to do from the command line. I had a gist of a script for doing this. It has now been incorporated into the ipa_sign script in https://github.com/RichardBronosky/ota-toolswhich I use daily. If you have any questions about using these tools, don't hesitate to ask.

从命令行执行非常容易。我有一个脚本的要点来做这件事。它现在已被合并到我每天使用的https://github.com/RichardBronosky/ota-tools 中的 ipa_sign 脚本中。如果您对使用这些工具有任何疑问,请随时提出。

The heart of it is this:

它的核心是这样的:

IPA="/path/to/file.ipa"
PROVISION="/path/to/file.mobileprovision"
CERTIFICATE="Name of certificate: To sign with" # must be in keychain
# unzip the ipa
unzip -q "$IPA"
# remove the signature
rm -rf Payload/*.app/_CodeSignature
# replace the provision
cp "$PROVISION" Payload/*.app/embedded.mobileprovision
# sign with the new certificate (--resource-rules has been deprecated OS X Yosemite (10.10), it can safely be removed)
/usr/bin/codesign -f -s "$CERTIFICATE" Payload/*.app
# zip it back up
zip -qr resigned.ipa Payload

Your new signed app is called resigned.ipa

您的新签名应用程序名为 resigned.ipa

回答by Blitz

Check iResignfor an easy tool on how to do this!

检查iResign以获取有关如何执行此操作的简单工具!

[edit] after some fudling around, I found a solution to keychain-aware resigning. You can check it out at https://gist.github.com/Weptun/5406993

[编辑] 经过一番摸索,我找到了一个解决钥匙串感知辞职的方法。您可以在https://gist.github.com/Weptun/5406993查看

回答by BryanH

Kind of old question, but with the latest XCode, codesignis easy:

有点老问题,但使用最新的 XCode,codesign很容易:

$ codesign -s my_certificate example.ipa 

$ codesign -vv example.ipa
example.ipa: valid on disk
example.ipa: satisfies its Designated Requirement

回答by simonseyer

The answers posted here all didn't quite work for me. They mainly skipped signing embedded frameworks (or including the entitlements).

此处发布的答案对我来说都不太适用。他们主要跳过签署嵌入式框架(或包括权利)。

Here's what's worked for me (it assumes that one ipa file exists is in the current directory):

这是对我有用的内容(假设当前目录中存在一个 ipa 文件):

PROVISION="/path/to/file.mobileprovision"
CERTIFICATE="Name of certificate: To sign with" # must be in the keychain

unzip -q *.ipa
rm -rf Payload/*.app/_CodeSignature/

# Replace embedded provisioning profile
cp "$PROVISION" Payload/*.app/embedded.mobileprovision

# Extract entitlements from app
codesign -d --entitlements :entitlements.plist Payload/*.app/

# Re-sign embedded frameworks
codesign -f -s "$CERTIFICATE" --entitlements entitlements.plist Payload/*.app/Frameworks/*

# Re-sign the app (with entitlements)
codesign -f -s "$CERTIFICATE" --entitlements entitlements.plist Payload/*.app/

zip -qr resigned.ipa Payload

# Cleanup
rm entitlements.plist
rm -r Payload/

回答by mattliu

Fastlane's sighprovides a fairly robust solution for resigning IPAs.

Fastlane 的叹息为 IPA 的辞职提供了一个相当强大的解决方案。

From their README:

从他们的自述文件:

Resign

If you generated your ipafile but want to apply a different code signing onto the ipa file, you can use sigh resign:

fastlane sigh resign

sighwill find the ipa file and the provisioning profile for you if they are located in the current folder.

You can pass more information using the command line:

fastlane sigh resign ./path/app.ipa --signing_identity "iPhone Distribution: Felix Krause" -p "my.mobileprovision"

辞职

如果您生成了ipa文件,但想要将不同的代码签名应用到 ipa 文件,您可以使用sigh resign

fastlane sigh resign

sigh如果它们位于当前文件夹中,则会为您找到 ipa 文件和配置文件。

您可以使用命令行传递更多信息:

fastlane sigh resign ./path/app.ipa --signing_identity "iPhone Distribution: Felix Krause" -p "my.mobileprovision"

It will even handle provisioning profiles for nested applications(eg. if you have watchkit apps)

它甚至可以处理嵌套应用程序的配置文件(例如,如果您有 watchkit 应用程序)

回答by Pierre Priot

I've updated Bryan's code for my Sierra iMac:

我已经为我的 Sierra iMac 更新了 Bryan 的代码:

# this version was tested OK vith macOs Sierra 10.12.5 (16F73) on oct 0th, 2017
# original ipa file must be store in current working directory 

IPA="ipa-filename.ipa"
PROVISION="path-to.mobileprovision"
CERTIFICATE="hexadecimal-certificate-identifier" # must be in keychain
# identifier maybe retrieved by running: security find-identity -v -p codesigning

# unzip the ipa
unzip -q "$IPA"

# remove the signature
rm -rf Payload/*.app/_CodeSignature

# replace the provision
cp "$PROVISION" Payload/*.app/embedded.mobileprovision

# generate entitlements for current app
cd Payload/
codesign -d --entitlements - *.app > entitlements.plist
cd ..
mv Payload/entitlements.plist entitlements.plist

# sign with the new certificate and entitlements
/usr/bin/codesign -f -s "$CERTIFICATE" '--entitlements' 'entitlements.plist'  Payload/*.app

# zip it back up
zip -qr resigned.ipa Payload

回答by Dharmesh Siddhpura

  1. Unzip the .ipa file by changing its extension with .zip
  2. Go to Payload. You will find .app file
  3. Right click the .app file and click Show package contents
  4. Delete the _CodeSignedfolder
  5. Replace the embedded.mobileprovisionfile with the new provision profile
  6. Go to KeyChain Access and make sure the certificate associated with the provisional profile is present
  7. Execute the below mentioned command: /usr/bin/codesign -f -s "iPhone Distribution: Certificate Name" --resource-rules "Payload/Application.app/ResourceRules.plist" "Payload/Application.app"

  8. Now zip the Payload folder again and change the .zip extension with .ipa

  1. 通过使用 .zip 更改其扩展名来解压缩 .ipa 文件
  2. 转到有效载荷。你会发现 .app 文件
  3. 右键单击 .app 文件,然后单击显示包内容
  4. 删除_CodeSigned文件夹
  5. embedded.mobileprovision新的配置文件替换文件
  6. 转到 KeyChain Access 并确保存在与临时配置文件关联的证书
  7. 执行下面提到的命令: /usr/bin/codesign -f -s "iPhone Distribution: Certificate Name" --resource-rules "Payload/Application.app/ResourceRules.plist" "Payload/Application.app"

  8. 现在再次压缩有效载荷文件夹,​​并改变.zip扩展用的.ipa

Hope this helpful.

希望这有帮助。

For reference follow below mentioned link: http://www.modelmetrics.com/tomgersic/codesign-re-signing-an-ipa-between-apple-accounts/

参考下面提到的链接:http: //www.modelmetrics.com/tomgersic/codesign-re-signing-an-ipa-between-apple-accounts/

回答by honcheng

Try this app http://www.ketzler.de/2011/01/resign-an-iphone-app-insert-new-bundle-id-and-send-to-xcode-organizer-for-upload/

试试这个应用程序 http://www.ketzler.de/2011/01/resign-an-iphone-app-insert-new-bundle-id-and-send-to-xcode-organizer-for-upload/

It supposed to help you resign the IPA file. I tried it myself but couldn't get pass an error with Entitlements.plist. Could just be a problem with my project. You should give it a try.

它应该可以帮助您退出 IPA 文件。我自己尝试过,但无法通过 Entitlements.plist 传递错误。可能只是我的项目有问题。你应该试一试。