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

发布于 2024-08-23 00:03:35 字数 1002 浏览 7 评论 0原文

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

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

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

  • 从 Xcode 项目构建和签名的应用程序中
  • (我不想手动解析 project.pbxproj 文件,因为此解决方案可能会在下一个 Xcode 更新中中断)
  • 任何其他可编写脚本的方式

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


这是我尝试过的:

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

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

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

我研究了使用协同设计,并且命令

/usr/bin/codesign -d -vvv --entitlements - -r - /Users/lv/Desktop/TicTacBoo.app/TicTacBoo
looked promising, but it doesn't give me the information I need.
I haven't found any useful option in xcodebuild either.

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

I would like to edit this script to output the name of the Provisioning Profile used 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.

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

Unforgiven suggested to use the command security to 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?


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:

/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

looked promising, but it doesn't give me the information I need.
I haven't found any useful option in xcodebuild either.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

不再让梦枯萎 2024-08-30 00:03:36

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

man security

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

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

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

security find-identity -p codesigning -v;

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

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

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

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

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

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.

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

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

夏有森光若流苏 2024-08-30 00:03:36

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

这是使用 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

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

How about looking in the _CodeSignature/CodeResources plist file (of the built application) for files of type "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...

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")

ˇ宁静的妩媚 2024-08-30 00:03:35

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

它的名称为 YourApplication.app/embedded.mobileprovision

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

The provisioning profile is already in the 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.)

It's named 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文