简体   繁体   English

通过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

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. 我有一个CI构建机器运行Xcode服务器并使用机器人生成构建,但是通过机器人构建的.ipa无权注册APNS令牌。

Specifically, didFailToRegisterForRemoteNotificationsWithError gets called and there is a runtime warning of ""No valid 'aps-environment' entitlement string found for application". 具体来说,调用didFailToRegisterForRemoteNotificationsWithError并且存在运行时警告“”没有为应用程序找到有效的'aps-environment'权利字符串“。

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. 但是,如果我在separte开发PC上构建应用程序,或者我实际上是在机器上独立于机器人构建它,那么一切都很好。

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. 我已经在多个应用程序中广泛使用了推送通知,因此要知道如果应用程序尚未使用正确的配置文件进行签名,则始终会显示消息“找不到应用程序的无效'aps-environment'权利字符串”。 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. 但是,当我手动构建它时,我绝对100%确认应用程序是在构建机器人时使用相同的配置文件构建的。

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. 我也知道Xcode在机器人下运行时为不同的位置下载配置文件到为用户运行时,我也知道机器人在我手动构建时作为系统而不是登录用户运行。 I have taken all these differences into consideration but am still unable to get the bot build to work. 我已经考虑了所有这些差异,但仍然无法使机器人构建工作。

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! 更有甚者,我使用这个完全相同的CI机器以前使用Jenkins(也作为系统运行)构建此应用程序,启用了推送,它工作正常!

These is what I have done/checked: 这些是我做过/检查过的:

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. 1)手动将项目下载到桌面,在Xcode中打开并检查构建设置中的签名身份和配置文件。 Build and run it manually using Xcode -> it works Download the project indirectly via the bot as part of its integration run. 使用Xcode手动构建和运行它 - >它的工作原理通过bot间接下载项目作为其集成运行的一部分。 Open the project downloaded by the Bot in Xcode (the Xcode server downloads it to: /Library/Server/Xcode/Data/BotRuns//Cache/NNNN). 打开由Xot中的Bot下载的项目(Xcode服务器将其下载到:/ 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) 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). 2)当你手动运行Xcode时,它会将配置文件下载到位置X,但是Bot会将配置文件下载到位置Y.所以我检查了X和Y的内容,以确保Y中没有任何遗漏(如果有的话)然而,构建实际上会失败,但它没有。

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的全部内容复制到Y并再次运行机器人(它们不会被机器人覆盖) - 所以现在机器人和桌面版本使用完全相同的副本但是.ipa执行时仍然存在差异。

Incidentally the location of X is ~/Library/MobileDevice/Provisioning Profiles and that of Y is / Library/Server/Xcode/Data/ProvisioningProfiles. 顺便提一下,X的位置是〜/ Library / MobileDevice / Provisioning Profiles,Y的位置是/ Library / Server / Xcode / Data / ProvisioningProfiles。

3) When I build manually it is as the logged in user, but when the bot build it is as the system. 3)当我手动构建时,它就像登录用户一样,但是当构建机器人时,它就像系统一样。 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. 是的,它没有任何区别,构建机器人创建的.ipa无法正常运行,而通过Xcode手动创建的构建运行。

This is driving me mad and has wasted days already, what else could I have missed or could try to resolve this? 这让我很生气,已经浪费了几天,还有什么我可能错过或者可以尝试解决这个问题?

Any suggestions or ideas? 有什么建议或想法吗?

在此输入图像描述

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. 我很想到原因是由于机器人系统中的一个错误,它错误地期望有一个权利文件。

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. 我发现bot构建失败的原因是因为bot没有将aps-environment权利放入.app文件中,即使该权利在embedded.mobileprovision中。 But XCode does insert it into the .app file if built manually or an archive is built. 但是如果手动构建或构建了存档,XCode会将其插入到.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. 此外,我发现如果我使用Entitlements.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 5 - entitlement.plist文件已经成为过去,所以没有必要使用一个只是强制机器人将权利放入.app,因此我怀疑它可能是一个机器人错误。

Are you tried to unzip your .ipa and check embedded.mobileprovision they should be the same. 您是否尝试解压缩.ipa并检查embedded.mobileprovision它们应该是相同的。 Also just for sure check that you not use developer profile to release build in bot/xcode. 另外,请确保您不使用开发人员配置文件来发布bot / xcode中的内置版本。

Shooting in the dark: 在黑暗中拍摄:

Although you said that the provisioning profile works great when you are running the build manually, have you tried creating a new provision profile from scratch and use that on the CI build machine using the bot? 虽然您说在手动运行构建时配置文件很有效,但您是否尝试过从头开始创建新的配置文件并使用机器人在CI构建机器上使用它?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM