xcode 捆绑标识符和推送证书... aps-environment 权利错误

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

Bundle Identifier and push certificate... aps-environment entitlement error

xcodepushios-provisioningsettings.bundle

提问by JulianB

I've read Where does xcode take application's Identifier from?, XCode bundle identifier formatting from {PRODUCT_NAME}, and loads more but...

我读过xcode 从哪里获取应用程序的标识符?来自 {PRODUCT_NAME} 的 XCode 包标识符格式,并加载更多但...

I'm trying to get push notifications going and getting the dreaded

我正在尝试让推送通知继续进行并让我感到害怕

"Error Domain=NSCocoaErrorDomain Code=3000 "no valid 'aps-environment' entitlement string found for application" UserInfo=0x15b200 {NSLocalizedDescription=no valid 'aps-environment' entitlement string found for application}" error.

“错误域=NSCocoaErrorDomain 代码=3000“没有为应用程序找到有效的‘aps-environment’授权字符串”UserInfo=0x15b200 {NSLocalizedDescription=没有为应用程序找到有效的‘aps-environment’授权字符串}”错误。

I'm fairly certain I've followed all the steps correctly, including:

我相当确定我已经正确地遵循了所有步骤,包括:

  • made the push certificate well in advance of the provisioning cert
  • made a 'Entitlements.plist'
  • added a get-task-allow boolean and set it to true (ad-hoc release)
  • 在配置证书之前制作推送证书
  • 做了一个'Entitlements.plist'
  • 添加了一个 get-task-allow 布尔值并将其设置为 true(临时版本)

The only think I can't quite get my head around is the Bundle Identifier

唯一让我无法理解的是 Bundle Identifier

The push certificate is for

推送证书用于

XXXXXXXXXX.com.julianbaker.pwcnewsuk

The Bundle Indentifier in PwCNewUK-Info.plist is for

PwCNewUK-Info.plist 中的捆绑标识符用于

com.julianbaker.${PRODUCT_NAME:rfc1034identifier}

If I manually change it to

如果我手动将其更改为

com.julianbaker.pwcnewsuk

I get a UDID mismatch error as the app is seen as PwCNewsUK

我收到 UDID 不匹配错误,因为该应用程序被视为 PwCNewsUK

When I've Googled this there seems to be some confusion over the matter, but it seems they have to match?

当我用谷歌搜索这个时,似乎对这个问题有些困惑,但似乎它们必须匹配?

QUESTION:

题:

What should the Bundle Indentifer be to match the push certificate of
XXXXXXXXXX.com.julianbaker.pwcnewsuk ?

Bundle Indentifer 应该是什么来匹配
XXXXXXXXXX.com.julianbaker.pwcnewsuk的推送证书?

QUESTION:

题:

Do I need to add a "aps-environment" entitlement to the provisioning profile, and if so where and how? (See http://www.airplaysdk.com/node/3174amongst others)

我是否需要在配置文件中添加“aps-environment”权限,如果需要,在哪里以及如何添加?(参见http://www.airplaysdk.com/node/3174等)

Loving iPhone development but sheesh it can be a headbanger at times!

热爱 iPhone 的开发,但有时它可能会让人头疼!

回答by J.R. Armstrong

I found this question when I was moving from a development environment to a production one on an application that I am working on. This process involved the creation of a new profile, a new app ID, etc. I created the app ID and a profile, but the Team Agent had to configure the push notifications. I ran into the problem of "no valid 'aps-environment' entitlement string found for application" when I tried to resume testing with the new profile (after the app had been configured for push notifications). I then remembered reading a little caveat in the documentation:

当我在我正在处理的应用程序上从开发环境转移到生产环境时,我发现了这个问题。此过程涉及创建新配置文件、新应用程序 ID 等。我创建了应用程序 ID 和配置文件,但团队代理必须配置推送通知。当我尝试使用新配置文件恢复测试时(在应用程序配置为推送通知之后),我遇到了“没有为应用程序找到有效的‘aps-environment’权利字符串”的问题。然后我记得在文档中阅读了一些警告:

"You have to modify the profile in some way (for example, toggle an option) for the portal to generate a new provisioning profile. If the profile isn't so "dirtied", you're given the profile without the push entitlements."

“您必须以某种方式修改配置文件(例如,切换选项),以便门户生成新的配置文件。如果配置文件不是那么“脏”,您将获得没有推送权限的配置文件。 ”

Source: Local and Push Notification Programming Guide

来源:本地和推送通知编程指南

For me, "dirtying" the provisioning profile and reinstalling it was all that was needed to fix the issue. Per the documentation, this was required because the provisioning profile was created before the app was configured for push notifications. This may or may not help anyone, but this probably explains (and eliminates) the need to manually add anything to the provisioning profile.

对我来说,“弄脏”配置文件并重新安装它就是解决问题所需的全部内容。根据文档,这是必需的,因为在为推送通知配置应用程序之前创建了配置文件。这可能对任何人都有帮助,也可能没有帮助,但这可能解释了(并消除了)手动向配置文件添加任何内容的需要。

回答by ozz

I ran into the same "no valid 'aps-environment' entitlement string found for application" problem, but the above solutions did not work for me.

我遇到了同样的“没有为应用程序找到有效的‘aps-environment’权利字符串”问题,但上述解决方案对我不起作用。

I could not find very good documentation about this error or even just the key "aps-environment".

我找不到关于此错误的非常好的文档,甚至找不到关键的“aps-environment”。

After some tinkering around, here is what solved the problem for me:

经过一番修修补补,以下是为我解决问题的方法:

Open your development provisioning certificate, "Appname.mobileprovision" with a text editor, look for the key "Entitlements" then add all of the values found here to your Entitlements file referenced by your Code Signing Entitlements setting.

使用文本编辑器打开您的开发供应证书“Appname.mobileprovision”,查找密钥“权利”,然后将此处找到的所有值添加到您的代码签名权利设置引用的权利文件中。

Here is an example of what keys/values you'll find inside:

以下是您将在其中找到的键/值的示例:

<key>application-identifier</key>
<string>xyz.com.xyz.xyz</string>
<key>aps-environment</key>
<string>development</string>
<key>com.apple.developer.ubiquity-container-identifiers</key>
<array>
<string>xyz.*</string>
</array>
<key>com.apple.developer.ubiquity-kvstore-identifier</key>
<string>xyz.*</string>
<key>get-task-allow</key>
<true/>
<key>keychain-access-groups</key>
<array>
<string>xyz.*</string>
</array>

After adding all of these values to my Entitlements file my app builds successfully and I can finally get back to working on Push Notifications.

将所有这些值添加到我的权利文件后,我的应用程序构建成功,我终于可以重新开始处理推送通知了。

I'm not sure if these values are supposed to be automatically added to your entitlements file by XCode, but they certainly weren't being generated for me in my project.

我不确定这些值是否应该由 XCode 自动添加到您的权利文件中,但它们肯定不是在我的项目中为我生成的。

回答by vinzenzweber

Setup:

设置:

Mac OS X 10.8 + Xcode 4.4

Mac OS X 10.8 + Xcode 4.4

My Simple Solution:

我的简单解决方案:

  1. Reissue your ad hoc provisioning profile after you have setup push notifications for your app ID and import them to Xcode.
  2. Take a look into your .xcodeproj folder (right click -> Show Package Contents) and delete the xcuserdatafolder.
  3. That's it ;)
  1. 在为您的应用程序 ID 设置推送通知并将它们导入 Xcode 后,重新发布您的临时配置文件。
  2. 查看您的 .xcodeproj 文件夹(右键单击 -> 显示包内容)并删除该xcuserdata文件夹。
  3. 就是这样 ;)

Some hints on that issue:

关于这个问题的一些提示:

After activating Push Notifications for my app I suddenly couldn't create ad hoc files anymore. I ran across errors in my Console log on my iPhone while trying to install my app such as those:

为我的应用程序激活推送通知后,我突然无法再创建临时文件。在尝试安装我的应用程序时,我在 iPhone 上的控制台日志中遇到了错误,例如:

Apr  1 20:56:10 unknown installd[384] <Error>: entitlement 'keychain-access-groups' has value not permitted by a provisioning profile
Apr  1 20:56:10 unknown installd[384] <Error>: entitlement 'get-task-allow' has value not permitted by a provisioning profile
Apr  1 20:56:10 unknown installd[384] <Error>: entitlement 'application-identifier' has value not permitted by a provisioning profile
Apr  1 20:56:10 unknown installd[384] <Error>: 2ff66000 verify_signer_identity: Could not copy validate signature: -402620394
Apr  1 20:56:11 unknown installd[384] <Error>: 2ff66000 preflight_application_install: Could not verify executable at /var/tmp/install_staging.44jV0O/foo_extracted/Payload/PersonalTrainer-Tester-iPhone.app
Apr  1 20:56:11 unknown com.apple.itunesstored[392] <Notice>: MobileInstallationInstall: failed with -1
Apr  1 20:56:11 unknown installd[384] <Error>: 2ff66000 install_application: Could not preflight application install
Apr  1 20:56:11 unknown installd[384] <Error>: 2ff66000 handle_install: API failed
Apr  1 20:56:11 unknown installd[384] <Error>: 2ff66000 send_message: failed to send mach message of 71 bytes: 10000003
Apr  1 20:56:11 unknown installd[384] <Error>: 2ff66000 send_error: Could not send error response to client

There is some technical notewhich recommends using codesign -d --entitlements - <YourAppName>.appto check if your app is signed properly for Apple Push Notifications. In case the output of the codesign command does not have an aps-environment set to production or development there is something fishy!

有一些技术说明建议使用它codesign -d --entitlements - <YourAppName>.app来检查您的应用程序是否为 Apple 推送通知正确签名。如果 codesign 命令的输出没有将 aps-environment 设置为 production 或 development 有一些可疑的东西!

As far as I knew so far, my apps signed with an adhoc provisioning profile always have an embedded.mobileprovisioninside the <YourAppName>.appfolder with a specific part in them such as:

到目前为止,据我所知,使用临时配置文件签名的应用程序始终embedded.mobileprovision<YourAppName>.app文件夹中包含一个特定部分,例如:

<key>Entitlements</key>
<dict>
    <key>application-identifier</key>
    <string>ABCDEFGH.com.myappname.tester</string>
    <key>aps-environment</key>
    <string>production</string>
    <key>get-task-allow</key>
    <false/>
    <key>keychain-access-groups</key>
    <array>
        <string>ABCDEFGH.*</string>
    </array>
</dict>

After using codesign I realized that the actual binary in <YourAppName>.apphad some XML included as well, which said something very different than my embedded.mobileprovisionfile:

使用 codesign 后,我意识到实际的二进制文件中<YourAppName>.app也包含了一些 XML,这与我的embedded.mobileprovision文件非常不同:

<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>application-identifier</key>
    <string>ABCDEFGH.com.myappname.tester</string>
    <key>get-task-allow</key>
    <true/>
    <key>keychain-access-groups</key>
    <array>
        <string>ABCDEFGH.com.myappname.tester</string>
    </array>
</dict>
</plist>

I assume this is the cause for the error message we are all experiencing. (although this error can have some different roots as well as other posts on stackoverflow suggest)

我认为这是我们都遇到的错误消息的原因。(虽然这个错误可能有一些不同的根源以及 stackoverflow 上的其他帖子建议)

The executable was signed with invalid entitlements.
The entitlements specified in your application's Code Signing Entitlements
file do not match those specified in your provisioning profile. (0xE8008016).

My guess is that there is some bug in Xcode which keeps the settings in your plist from being updated in you schemes which then causes your app to be signed with the wrong provisioning profile in the end. So by deleting the xcuserdata folder you delete all schemes. Therefore Xcode will recreate them next time with the proper settings and you are happy again.

我的猜测是 Xcode 中存在一些错误,它使您的 plist 中的设置无法在您的方案中更新,从而导致您的应用程序最终使用错误的配置文件进行签名。因此,通过删除 xcuserdata 文件夹,您将删除所有方案。因此,Xcode 将在下次使用正确的设置重新创建它们,您会再次感到高兴。

回答by JulianB

Essentially the answer is the same vague one everyone else says

基本上答案和其他人说的一样含糊不清

  • Make sure you have a "Entitlements.plist" added (New File/Code Signing/Entitlements)
  • Add "get-task-allow" (Boolean Off) to Entitlements.plist
  • Add "aps-environment" "production" pair to Entitlements.plist -- This last step may be unnecessary but it was one of the steps I did just before it worked
  • Delete old mobileprovision files from iPhone/iPod (In Settings/General),
  • Delete old mobileprovision files from XCode Organiser
  • Delete App from iPhone/iPod
  • Quit XCode
  • Download fresh copy of Provisioning Certificate
  • Check for "aps-environment" "production" pair in certificate with a Text Editor
  • Start XCode
  • Add fresh mobileprovision file by dragging to XCode Doc icon
  • Make sure you have reassigned/assigned the correct certificate in the Target Info : Code Signing : Code Signing Identity
  • Double check that the Build Results to see it it's using the correct profile and is signed correctly
  • 确保添加了“Entitlements.plist”(新文件/代码签名/权利)
  • 将“get-task-allow”(布尔关闭)添加到 Entitlements.plist
  • 向 Entitlements.plist 添加“aps-environment”“production”对——这最后一步可能是不必要的,但它是我在它工作之前所做的步骤之一
  • 从 iPhone/iPod 中删除旧的 mobileprovision 文件(在设置/常规中),
  • 从 XCode Organizer 中删除旧的 mobileprovision 文件
  • 从 iPhone/iPod 删除应用程序
  • 退出 XCode
  • 下载配置证书的新副本
  • 使用文本编辑器检查证书中的“aps-environment”“生产”对
  • 启动 XCode
  • 通过拖动到 XCode Doc 图标添加新的 mobileprovision 文件
  • 确保您已在 Target Info : Code Signing : Code Signing Identity 中重新分配/分配了正确的证书
  • 仔细检查构建结果以查看它是否使用正确的配置文件并正确签名

Repeat these steps calmly until it works, took me about five goes of various combinations. I also switched from Development to Ad-hoc which apparently isn't necessary but did guarantee a new mobileprovision file.

平静地重复这些步骤直到它起作用,我花了大约五次各种组合。我也从 Development 切换到 Ad-hoc,这显然不是必需的,但确实保证了新的 mobileprovision 文件。

回答by Max Ogden

Using XCode4 and receiving the same "no valid 'aps-environment' entitlement string found for application" I had to do the following:

使用 XCode4 并收到相同的“未找到适用于应用程序的有效‘aps-environment’权利字符串”,我必须执行以下操作:

  • Delete old provisioning profiles from both Library + Device panels in Organizer
  • Regenerate new profile with APN dev enabled from the developer portal website
  • Make sure new profile is added to both Library + Device panels in Organizer
  • Manually delete my app off my device (holding till it jiggles and hitting X)
  • CMD+OPT+SHIFT+K (Clean Build Folder) and CMD+SHIFT+K (Clean)
  • Set the proper profile under Project > Build Settings > Code Signing
  • Make sure 'Use Entitlements' is not checked under Targets > Summary
  • 从管理器中的库 + 设备面板中删除旧的配置文件
  • 从开发者门户网站启用 APN dev 重新生成新配置文件
  • 确保将新配置文件添加到管理器中的库 + 设备面板
  • 从我的设备上手动删除我的应用程序(按住直到它摇晃并点击 X)
  • CMD+OPT+SHIFT+K(清理构建文件夹)和 CMD+SHIFT+K(清理)
  • 在 Project > Build Settings > Code Signing 下设置正确的配置文件
  • 确保未选中“目标”>“摘要”下的“使用权利”

回答by Steffo

Under 'Project' -> 'Build Settings' -> 'Code Signing', make sure you have selected the correct Provisioning profile (the one with push enabled).

在“项目”->“构建设置”->“代码签名”下,确保您选择了正确的供应配置文件(启用推送的配置文件)。

That was all I needed to change in order to make it work.

这就是我需要改变以使其工作的全部内容。

回答by DeZigny

None of the above worked for me!

以上都不适合我!

  1. Delete all Provisioning Profilesin Xcode Organizer
  2. Delete all Developers certificatesin Keychain
  3. Delete all Provisioning Profilesin iPhone device
  4. In iOS Provisioning Portal, delete Development Provisioning Profilewhich was created automatically by Xcode
  5. Create a new Provisioning Profileby assigning the correct (Certificate/AppID/Device) combination
  6. Download the new Provisioning Profile
  7. Import the new Provisioning Profileinto Xcode Organizer
  8. CMD + Option + Shift + K
  9. CMD + Shift + K
  10. CMD + R
  11. Hooray:)
  1. 删除所有部署配置文件Xcode的组织者
  2. 删除所有开发者证书钥匙扣
  3. 删除所有预置描述文件iPhone设备
  4. iOS Provisioning Portal 中,删除由Xcode自动创建的Development Provisioning Profile
  5. 通过分配正确的(证书/AppID/设备)组合创建一个新的配置文件
  6. 下载新的配置文件
  7. 将新的Provisioning Profile导入Xcode Organizer
  8. CMD + Option + Shift + K
  9. CMD + Shift + K
  10. CMD + R
  11. 万岁:)

回答by Will

Make sure that you are using the app in the correct way with the provisioning profile.

确保您通过配置文件以正确的方式使用该应用程序。

What I mean is that if you've enabled your app for Push notifications for Distribution only, and you are trying to get push notifications to work via building with XCode, this will not work.

我的意思是,如果您只为分发启用了推送通知的应用程序,并且您试图通过使用 XCode 构建来使推送通知工作,这将不起作用。

I ran into this problem, and by enabling push notification for Development for the App ID, and then using the development provisioning profile I no longer got the error and the correct alert view asked if I wanted to get push notifications.

我遇到了这个问题,通过为 App ID 启用开发推送通知,然后使用开发配置文件,我不再收到错误,正确的警报视图询问我是否想要收到推送通知。

回答by Flori

the solution for 10.8 Xcode 4.4 is to open the appname.entitlementsfile

10.8 Xcode 4.4 的解决方案是打开appname.entitlements文件

and if the DataProtectionClasskey has the value NSFileProtectionComplete, delete it!

如果DataProtectionClass键有值NSFileProtectionComplete,删除它!

Deleting this key allows me to test apps from Xcode on devices (it wasn't affecting simulation).

删除此密钥允许我在设备上从 Xcode 测试应用程序(它不影响模拟)。

回答by Hersker

I had the same problem. For me the fix was like this:

我有同样的问题。对我来说,修复是这样的:

  1. Removed and reloaded the provisioning profiles from the organizer.
  2. Selected my named provisioning profile under project settings->code signing. Somehow it wanted to use the blabla.* identity.
  1. 从管理器中删除并重新加载配置文件。
  2. 在项目设置-> 代码签名下选择了我的命名配置文件。不知何故,它想使用 blabla.* 身份。

The wildcard profile ([prefix].*) won't do when your trying to run a APN enabled application, you need to specify the APN enabled profile.

当您尝试运行启用 APN 的应用程序时,通配符配置文件 ([prefix].*) 不起作用,您需要指定启用 APN 的配置文件。