通过 Xcode bot 创建的 IPA 无法为 APNS 运行,但如果通过 Xcode 本身手动构建或由 Xcode 构建为存档,则可以运行 [英] IPA created via Xcode bot fails to run for APNS but runs if built manually via Xcode itself or built as an archive by Xcode

查看:24
本文介绍了通过 Xcode bot 创建的 IPA 无法为 APNS 运行,但如果通过 Xcode 本身手动构建或由 Xcode 构建为存档,则可以运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一台运行 Xcode 服务器并使用机器人生成构建的 CI 构建机器,但是通过机器人构建的 .ipa 无权注册 APNS 令牌.

I have a CI build machine running Xcode server and using a bot to generate a build, however the .ipa built via the bot is not being entitled to register for the APNS token.

具体来说,didFailToRegisterForRemoteNotificationsWithError 被调用并且有一个运行时警告没有为应用程序找到有效的‘aps-environment’权利字符串".

Specifically, didFailToRegisterForRemoteNotificationsWithError gets called and there is a runtime warning of ""No valid 'aps-environment' entitlement string found for application".

但是,如果我在单独的开发 PC 上构建应用程序,或者我在独立于机器人的 CI 机器上实际构建它,那么一切都很好.

However if I build the app on a separte development PC, or I build it actually on the CI machine independently of the bot then everything is fine.

我已在多个应用程序中广泛使用推送通知,因此知道如果应用程序未使用正确的配置文件签名,则始终会出现消息找不到应用程序的有效‘aps-environment’权利字符串".但是,我绝对 100% 确认该应用程序在作为机器人构建的一部分运行时与我手动构建时使用相同的配置文件构建.

I've used push notifications extensively in several apps so know that the message "No valid 'aps-environment' entitlement string found for application" always appears if the app has not been signed with the correct profiles. However I have absolutely 100% confirmed that the app is being built with the same profiles when running as part of the bot build to when I build it manually.

我还知道 Xcode 在机器人下运行到为用户运行时会将配置文件下载到不同的位置,而且我还知道,当我手动构建时,机器人作为系统运行,而不是作为登录用户运行.我已经考虑了所有这些差异,但仍然无法让机器人构建工作.

I also know that Xcode downloads provisioning profiles to different locations when running under the bot to when running for a user, and I also know that the bot runs as system and not the logged in user when I build manually. I have taken all these differences into consideration but am still unable to get the bot build to work.

更重要的是,我之前使用这台完全相同的 CI 机器来构建这个应用程序,使用 Jenkins(它也作为系统运行)启用推送并且它工作正常!

What's more I have used this exact same CI machine to previously build this app using Jenkins (which also ran as system) enabled for push and it worked!

这些是我做过/检查过的:

These is what I have done/checked:

1)手动将项目下载到桌面,在 Xcode 中打开并检查在构建设置中被起诉的签名身份和配置文件.使用 Xcode 手动构建并运行它 -> 它可以工作作为集成运行的一部分,通过机器人间接下载项目.在Xcode中打开Bot下载的项目(Xcode服务器下载到:/Library/Server/Xcode/Data/BotRuns//Cache/NNNN).做同样的事情,检查签名身份和配置文件.它们与我在桌面上构建时使用的相同

1) Download the project manually to the desktop, open in Xcode and examine the signing identity and provisioning profiles being sued in the build settings. Build and run it manually using Xcode -> it works Download the project indirectly via the bot as part of its integration run. Open the project downloaded by the Bot in Xcode (the Xcode server downloads it to: /Library/Server/Xcode/Data/BotRuns//Cache/NNNN). Do the same thing, check the signing identity and provisioning profiles. THEY ARE IDENTICAL to those used when I build on the desktop

好的,所以问题不是由于实际签名身份和所使用的配置文件的差异造成的.

OK so the problem is not due to a difference in the actual signing identity and provisioning profiles being used.

2) 当您手动运行 Xcode 时,它​​会将配置文件下载到位置 X,但 Bot 会将配置文件下载到位置 Y.所以我检查了 X 和 Y 的内容以确保 Y 中没有任何遗漏(如果有的话,构建实际上会失败,但事实并非如此).

2) When you run Xcode manually it downloads the provisioning profiles to location X, but the Bot downloads the provisioning profiles to location Y. So I have examined the contents of X and Y to make sure there is nothing missing from Y (if there was the build would actually fail however, which it doesn't).

为了确保它们完全相同,我将 X 的全部内容复制到 Y 中并再次运行机器人(它们不会被机器人覆盖) - 所以现在机器人和桌面版本使用完全相同当 .ipa 执行时,配置文件的副本仍然存在差异.

To make absolutely sure they are identical I have copied the entire contents of X into Y and run the bot again (they don't get overriden by the bot) - So now the bot and the desktop builds are using the exact same copies of the profiles yet still there is a difference when the .ipa executes.

顺便说一下,X 的位置是 ~/Library/MobileDevice/Provisioning Profiles,而 Y 的位置是/Library/Server/Xcode/Data/ProvisioningProfiles.

Incidentally the location of X is ~/Library/MobileDevice/Provisioning Profiles and that of Y is / Library/Server/Xcode/Data/ProvisioningProfiles.

3) 当我手动构建时,它作为登录用户,但当机器人构建时它作为系统.因此,在钥匙串中,我尝试将用户钥匙串中的所有证书和密钥复制到系统钥匙串中.是的,它仍然没有区别,构建机器人创建的 .ipa 无法正常运行,而通过 Xcode 手动创建的构建确实运行.

3) When I build manually it is as the logged in user, but when the bot build it is as the system. So within the keychain I have tried copying all the certificates and keys from the user's keychain into the system keychain. Yes still it makes no difference, the .ipa created by the build bot fails to run properly while the build created manually via Xcode does run.

这让我发疯并且已经浪费了几天,我还能错过什么或可以尝试解决这个问题吗?

This is driving me mad and has wasted days already, what else could I have missed or could try to resolve this?

有什么建议或想法吗?

推荐答案

我已找到确切原因,至于原因背后的原因我不知道,因此我将我的答案标记为已接受的答案,因为它至少是遇到相同问题的任何人的解决方法.我很想认为原因是由于机器人系统中的一个错误,该错误错误地期望有一个权利文件.

I have found the exact cause, as to the reason behind the cause I don't know, thus I'm marking mine as the accepted answer as it is at least a workaround to anybody who encounters the same problem. I'm tempted to think the reason is due to a bug in the bot system which is mistakenly expecting there to be an entitlements file.

我发现机器人构建失败的原因是机器人没有将 aps-environment 权利放入 .app 文件,即使该权利在 Embedded.mobileprovision 中.但如果手动构建或构建存档,XCode 确实会将其插入到 .app 文件中.

I've discovered that the reason the bot build fails is because the bot is not placing the aps-environment entitlement into the .app file even though that entitlement is within the embedded.mobileprovision. But XCode does insert it into the .app file if built manually or an archive is built.

此外,我发现如果我使用 Entitlements.plist,我可以强制机器人将必要的权利和相关信息放入 .app 文件中.

Also I've found that I can force the bot to put the necessary entitlement and associated information into the .app file if I use an Entitlements.plist.

但这是使用 Xcode 5 - entitlement.plist 文件已成为过去,因此没有必要使用一个来强制机器人将权利放入 .app,因此我怀疑它可能成为机器人错误.

But this is using Xcode 5 - entitlement.plist files are a thing of the past, so it should not be necessary to use one just to force the bot to place the entitlement into the .app, hence why I suspect it might be a bot bug.

这篇关于通过 Xcode bot 创建的 IPA 无法为 APNS 运行,但如果通过 Xcode 本身手动构建或由 Xcode 构建为存档,则可以运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆