xcode 用于签署 iPhone 应用程序的配置文件的名称?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2327257/
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-09-14 19:08:32  来源:igfitidea点击:

Name of Provisioning Profile used to sign an iPhone app?

iphonexcodebuild-automationprovisioningcodesign

提问by Guillaume

I wrote a script that uses xcodebuildto generate an AdHoc build of an iPhone application.

我编写了一个脚本,用于xcodebuild生成 iPhone 应用程序的 AdHoc 构建。

I would like to edit this script to output the name of the Provisioning Profileused to sign the build.
This would allow me to include the Provisioning Profile in the zip that is automatically generated. This way, I could automatically send the archive to the AdHoc testers and be sure that they have the right Provisioning Profile to install the app.

我想编辑此脚本以输出用于签署构建的配置文件的名称。
这将允许我在自动生成的 zip 中包含配置文件。通过这种方式,我可以自动将存档发送给 AdHoc 测试人员,并确保他们拥有正确的配置文件来安装应用程序。

Is there any way to extract the Provisioning Profile name or file used to sign the application:

有没有办法提取用于签署应用程序的配置文件名称或文件

  • from the builded and signed application
  • from the Xcode project (I don't want to manually parse the project.pbxproj file, as this solution might break in the next Xcode update)
  • any other way that is scriptable
  • 来自构建和签名的应用程序
  • 来自 Xcode 项目(我不想手动解析 project.pbxproj 文件,因为此解决方案可能会在下一次 Xcode 更新中中断)
  • 任何其他可编写脚本的方式


Unforgiven suggestedto use the command securityto get the name of the certificate used to sign the app. Once you have this information, is there any way to then find the name of the Provisioning Profile?

Unforgiven建议使用该命令security来获取用于签署应用程序的证书的名称。获得此信息后,是否有任何方法可以找到配置文件的名称?



Here is what I tried:

这是我尝试过的:

Sadly, the output of xcodebuild during the build does not contain this information. During the CodeSign step, there is the line:

遗憾的是,构建期间 xcodebuild 的输出不包含此信息。在 CodeSign 步骤中,有一行:

/usr/bin/codesign -f -s "iPhone Distribution: My name" ...

but I can't match this with a certificate.

但我无法将其与证书相匹配。

I looked into using codesign, and the command

我研究了使用协同设计,以及命令

/usr/bin/codesign -d -vvv --entitlements - -r - /Users/lv/Desktop/TicTacBoo.app/TicTacBoo
看起来很有希望,但它没有给我我需要的信息。


我也没有在 xcodebuild 中找到任何有用的选项。

回答by Jon-Eric

The provisioning profile is already inthe application. You don't need another copy in your zip file (unless your testers do not understand how to use the copy inside of the application.)

供应配置文件已应用程序中。您的 zip 文件中不需要另一个副本(除非您的测试人员不了解如何在应用程序内部使用该副本。)

It's named YourApplication.app/embedded.mobileprovision

它名为 YourApplication.app/embedded.mobileprovision

This doesn't answer your question because the original filename is lost, however it does seem to solve your bigger problem.

这不能回答您的问题,因为原始文件名丢失了,但它似乎确实解决了您的更大问题。

回答by Massimo Cafaro

You can use the "security" command from the terminal; unfortunately, at least on my MBP with Snow Leopard it appears to cause a segmentation fault in one of the commands you need to issue. For more information, issue from the terminal

您可以从终端使用“security”命令;不幸的是,至少在我的带有 Snow Leopard 的 MBP 上,它似乎会导致您需要发出的命令之一出现分段错误。有关更多信息,请从终端发出

man security

Anyway, here is what you can try, assuming your development/production certificates are stored in the login keychain:

无论如何,假设您的开发/生产证书存储在登录钥匙串中,您可以尝试以下方法:

security unlock-keychain login.keychain;
security find-certificate -a -c "iPhone Distribution: Your name"  -p > cert.pem;

The second command causes the segmentation fault (caused by the -c argument), but it should be exactly what you need. Alternatively, you can use

第二个命令会导致分段错误(由 -c 参数引起),但它应该正是您所需要的。或者,您可以使用

security find-identity -p codesigning -v;

to get a list of all of the valid certificates you can use to code sign your applications. For each certificate, the output also contains the SHA1 message digest, so that you can easily search the certificate in the keychain matching the SHA1 digest associated to "iPhone Distribution: Your name". This however, requires that you write your own application using the keychain APIs.

获取可用于对应用程序进行代码签名的所有有效证书的列表。对于每个证书,输出还包含 SHA1 消息摘要,以便您可以轻松地在与“iPhone 分发:您的姓名”关联的 SHA1 摘要匹配的钥匙串中搜索证书。但是,这要求您使用钥匙串 API 编写自己的应用程序。

Let me know if this works on your mac or if you experience the same segmentation fault issue.

让我知道这是否适用于您的 Mac,或者您是否遇到相同的分段错误问题。

EDIT/UPDATE: I have verified the bug on other machines and filed a bug to Apple.

编辑/更新:我已经验证了其他机器上的错误并向 Apple 提交了一个错误。

回答by David Gelhar

How about looking in the _CodeSignature/CodeResources plist file (of the built application) for files of type "mobileprovision"?

如何在 _CodeSignature/CodeResources plist 文件(内置应用程序的)中查找“mobileprovision”类型的文件?

Here's a way to do that using defaults(1) to read the plist file. You have to copy the CodeResources file to something with the ".plist" suffix to keep defaults happy...

这是一种使用 defaults(1) 读取 plist 文件的方法。您必须将 CodeResources 文件复制到带有“.plist”后缀的文件中,以保持默认值...

cp /build/Distribution-iphoneos/MyApp.app/_CodeSignature/CodeResources /tmp/defaults.plist
defaults read /tmp/defaults files |grep .mobileprovision |grep -v embedded.mobileprovision

(in my test case, there were 2 .mobileprovision entries there; ignore the one named "embedded.mobileprovision")

(在我的测试案例中,那里有 2 个 .mobileprovision 条目;忽略名为“embedded.mobileprovision”的条目)