ios 如何修复 Xcode 4.3 中的“没有为应用程序找到有效的‘aps-environment’权利字符串”?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10987102/
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
How to fix "no valid 'aps-environment' entitlement string found for application" in Xcode 4.3?
提问by jwl
I've been trying very very hard to create a simple simple iOS app which can recieve push notifications. My only reason for doing this is to establish a procedure for some other team members to use, and have not been able to find an up to date, working version of such instructions elsewhere on the web. Our shop is fairly new to iOS dev, I personally am completely inexperienced with iOS dev and Xcode. I've stumbled through tens of tutorials, articles, and trouble posts from Apple and elsewhere and I feel like I might be nearly there...
我一直在非常努力地尝试创建一个简单的 iOS 应用程序,它可以接收推送通知。我这样做的唯一原因是建立一个程序供其他一些团队成员使用,并且无法在网络上的其他地方找到此类说明的最新工作版本。我们的商店对 iOS 开发人员来说是相当新的,我个人对 iOS 开发人员和 Xcode 完全没有经验。我偶然发现了来自 Apple 和其他地方的数十篇教程、文章和问题帖子,我觉得我可能快到了……
Here is where I've got to (note I'm using Xcode 4.3 and trying initially to deploy just to iOS 5.1, and I gather that some things may have changed recently vs earlier versions of Xcode, but again I'm new to all this -- and finding it completely confusing and convoluted):
这是我必须要做的地方(请注意,我正在使用 Xcode 4.3 并尝试最初仅部署到 iOS 5.1,并且我认为最近与早期版本的 Xcode 相比,某些事情可能发生了变化,但我又是新手这 - 并发现它完全令人困惑和令人费解):
1) I've got a provisioning profile on my iPhone which has Push enabled
1) 我的 iPhone 上有一个启用了推送的配置文件
2) In my test Xcode project I've got that provisioning profile selected as the signing identity (in Build Settings > Code Signing)
2) 在我的测试 Xcode 项目中,我选择了该配置文件作为签名标识(在构建设置 > 代码签名中)
3) I've got my bundle identifier under Summary and Info > Custom iOS Target Properties set properly* (I think??)
3)我在摘要和信息>自定义iOS目标属性下设置了我的包标识符*(我认为??)
4) I've got registerForRemoteNotificationTypes being called in my delegate's didFinishLaunchingWithOptions
4) 我在委托的 didFinishLaunchingWithOptions 中调用了 registerForRemoteNotificationTypes
5) I've got didRegisterForRemoteNotificationsWithDeviceToken and didFailToRegisterForRemoteNotificationsWithError in my delegate, set up to log the device token or error respectively
5)我在我的委托中有 didRegisterForRemoteNotificationsWithDeviceToken 和 didFailToRegisterForRemoteNotificationsWithError,设置为分别记录设备令牌或错误
6) I've got Enable Entitlements checked under Summary.
6) 我在摘要下选中了启用权利。
7) Right below that the Entitlements File selected is Tinker6 (the name of my test project), which was generated automatically when I checked Enable Entitlements
7)在选择的权利文件的正下方是 Tinker6(我的测试项目的名称),它是在我选中启用权利时自动生成的
8) In the Tinker6.entitlements file I've got the following (which I've gathered is correct based on several different posts all over the web, but which I can't find anything definitive from Apple itself on):
8) 在 Tinker6.entitlements 文件中,我得到了以下内容(根据网络上的几个不同帖子,我收集到的内容是正确的,但我无法从 Apple 本身找到任何明确的内容):
Updated
更新
9) Also, I have tried the whole thing without an entitlements file, and get essentially the same result.
9) 另外,我在没有权利文件的情况下尝试了整个过程,并获得了基本相同的结果。
10) My mobileprovision file contents include entitlements properly (I've scrambled the number and domain but structurally the same):
10) 我的 mobileprovision 文件内容正确地包含了权限(我已经对数字和域进行了加扰,但结构上是相同的):
<key>application-identifier</key>
<string>12355456A7.com.whatever.tinker</string>
<key>aps-environment</key>
<string>development</string>
<key>get-task-allow</key>
<true/>
<key>keychain-access-groups</key>
<array>
<string>12355456A7.*</string>
</array>
/end update
/结束更新
When I attempt to run this on my device, I get the following error in Xcode output:
当我尝试在我的设备上运行它时,我在 Xcode 输出中收到以下错误:
2012-06-11 12:45:23.762 Tinker6[13332:707] Failed to get token, error:
Error Domain=NSCocoaErrorDomain Code=3000 "no valid 'aps-environment'
entitlement string found for application" UserInfo=0x24a3b0
{NSLocalizedDescription=no valid 'aps-environment' entitlement string
found for application}
I've tried setting get-task-allow to NO, aps-environment to production, all four possible combinations, same thing.
我试过将 get-task-allow 设置为 NO,将 aps-environment 设置为生产,所有四种可能的组合,同样的事情。
How can I get past this? Where is definitive documentation on this?
我怎样才能克服这个?这方面的权威文件在哪里?
-- further background follows--
——进一步的背景如下——
*As far as the bundle id, I am still not clear on how this should be set in relation to App Ids and Profile ids in the Provisioning profile. In the Provisioning portal under App Ids I have this (again, scrambled the number and domain):
*至于 bundle id,我仍然不清楚应该如何设置它与 Provisioning profile 中的 App Ids 和 Profile ids。在 App Ids 下的 Provisioning 门户中,我有这个(再次打乱数字和域):
And the two places bundle id is set I have this:
并且设置了两个地方 bundle id 我有这个:
I am not at all sure these are correct or whether one or both should be set to 12355456A7.com.whatever.tinker, though I've tried those earlier in the process with no success...
我完全不确定这些是否正确,或者是否应该将其中一个或两个都设置为 12355456A7.com.whatever.tinker,尽管我在此过程的早期尝试过这些但没有成功......
NoteI realize there are many posts with similar titles, however they all seem to be out of date based on the file names and so-forth given, and the fact none of the solutions seem to be useful. I'm hoping the greater level of detail I've given will warrant a quality response. I will probably assign a bounty as soon as possible and if you give a high quality answer that leads to a solution I will award you the bounty as well as promote your answer via twitter and my blog. Especially if you crosspost post a really good "here are the exact500 steps you need to get a simple push notification app working including provisioning and whatever else" article on your blog or whatever.
请注意,我意识到有许多具有类似标题的帖子,但是根据文件名等内容,它们似乎都已过时,而且事实上没有一个解决方案似乎有用。我希望我提供的更多细节将保证高质量的回应。我可能会尽快分配赏金,如果您提供高质量的答案以找到解决方案,我将奖励您并通过 Twitter 和我的博客宣传您的答案。尤其是如果您交叉发布了一篇非常好的“这里是让简单的推送通知应用程序工作所需的确切500 个步骤,包括配置和其他任何内容”文章在您的博客或其他内容上。
采纳答案by jwl
The answer was: start over, do everything the same but create a new provisioning profile, and install it. That worked. Inspecting all the details (entitlements in mobile provision) looks exactlythe same as everything in my question here. But now it works. Apple: WAT?
答案是:重新开始,做所有相同的事情,但创建一个新的配置文件,然后安装它。那奏效了。检查所有详细信息(移动配置中的权利)看起来与我在此处提出的问题中的所有内容完全相同。但现在它起作用了。苹果:哇?
Of course, it would have been obvious to do this ifit was possible to delete provisioning profiles. But since that's not possible, I didn't want to clutter our team with a bunch of test profiles. Still, finally lost patience and tried it anyway, and it ended up working. Whatevs.
当然,如果可以删除配置文件,那么这样做是显而易见的。但由于这是不可能的,我不想让我们的团队被一堆测试配置文件弄得乱七八糟。尽管如此,最终还是失去了耐心并尝试了它,它最终奏效了。什么。
回答by elp
If you created your provisioning profile before configuring the app ID
for push, try to regenerate the provisioning profile.
如果您在配置app ID
for push之前创建了配置文件,请尝试重新生成配置文件。
iOS Provisioning Portal -> Provisioning -> Your cert -> EDIT -> Make an edit -> Download new provisioning
iOS Provisioning Portal -> Provisioning -> Your cert -> EDIT -> Make an edit -> Download new provisioning
Worked for me. Now i'm able to use push.
为我工作。现在我可以使用推送了。
回答by Mike Weller
First of all, you don't need the entitlements file unless you are adding custom key/value pairs that do not exist in the provisioning profile. When your app is built, any entitlements from the provisioning profile will be copied to the app.
首先,除非您要添加配置文件中不存在的自定义键/值对,否则您不需要权利文件。构建您的应用程序时,配置文件中的任何权利都将复制到应用程序。
Given that you still see an error message about missing entitlements, I can only assume the code signing options are not correct in the build settings.
鉴于您仍然看到有关缺少权利的错误消息,我只能假设构建设置中的代码签名选项不正确。
You need to make sure the correct profile is selected for the "Debug" configuration, and to be safe, that you have selected the correct profile for both the "Debug" and child-node labelled "Any iOS SDK":
您需要确保为“调试”配置选择了正确的配置文件,并且为了安全起见,您为“调试”和标记为“任何 iOS SDK”的子节点选择了正确的配置文件:
Although this screenshot shows the "Automatic Developer" profile selected, choose the exact provisioning profile you want from the drop down, just for testing purposes. It could be that Xcode is automatically choosing a different profile than the one you want.
尽管此屏幕截图显示了选择的“自动开发人员”配置文件,但请从下拉列表中选择您想要的确切配置文件,仅用于测试目的。可能是 Xcode 自动选择了与您想要的不同的配置文件。
Also be sure to do a clean build, completely delete the app from your device, etc. This is just to make sure you don't have some old fluff hanging around.
还要确保进行干净的构建,从您的设备中完全删除该应用程序等。这只是为了确保您没有一些旧的绒毛。
回答by DipakSonara
回答by ooxio
Easiest way is to do this from your accounts with Xcode:
最简单的方法是使用 Xcode 从您的帐户中执行此操作:
Head over Xcode -> Preferences -> Choose Accounts Tab -> View Details -> Hit refresh button on the bottom left -> Done.
前往 Xcode -> Preferences -> Choose Accounts Tab -> View Details -> 点击左下角的刷新按钮 -> Done。
Build again and it should work.
再次构建,它应该可以工作。
回答by Max
Ok, I faced the problem before. Since push notification requires serverside implementation, for me recreating profile was not an option. So I found this solution WITHOUT creating new provisioning profile.
好的,我之前遇到过这个问题。由于推送通知需要服务器端实现,对我来说重新创建配置文件不是一个选项。所以我在没有创建新的配置文件的情况下找到了这个解决方案。
Xcode is not properly selecting the correct provisioning profile although we are selecting it correctly.
尽管我们正确选择了它,但 Xcode 没有正确选择正确的配置文件。
First go to organizer. On the Devices tab, Provisioning profile from Library list, select the intended profile we are trying to use. Right click on it and then "Reveal Profile in Finder".
首先去组织者。在设备选项卡上,从库列表中配置配置文件,选择我们尝试使用的预期配置文件。右键单击它,然后“在 Finder 中显示个人资料”。
The correct profile will be selected in the opened Finder window. Note the name.
将在打开的 Finder 窗口中选择正确的配置文件。注意名称。
Now go to Xcode > Log Navigator. Select filter for "All" and "All Messages". Now in the last phase(Build Target) look for the step called "ProcessProductPackaging" expand it. Note the provisioning profile name. They should NOT match if you are having the error.
现在转到 Xcode > Log Navigator。为“全部”和“所有消息”选择过滤器。现在在最后一个阶段(构建目标)中查找名为“ProcessProductPackaging”的步骤展开它。请注意配置文件名称。如果您遇到错误,它们不应该匹配。
Now in the Opened Finder window delete the rogue provisioning profile which Xcode is using. Now build again. The error should be resolved. If not repeat the process to find another rogue profile to remove it.
现在在 Opened Finder 窗口中删除 Xcode 正在使用的流氓配置文件。现在再次构建。应该解决该错误。如果没有重复该过程,找到另一个流氓配置文件将其删除。
Hope this helps.
希望这可以帮助。
回答by user1006117
Delete old provisioning profile from XCode in Organizer.
从管理器中的 XCode 中删除旧的配置文件。
Then, generate a new provisioning profile for the same bundle id in iOS provisioning portal (after you have enabled push).
然后,在 iOS 配置门户中为相同的 bundle id 生成一个新的配置文件(在您启用推送之后)。
Import the new provisioning profile in XCode, set it in your app build settings.
在 XCode 中导入新的配置文件,在您的应用程序构建设置中进行设置。
Build, run, it works.
构建,运行,它起作用了。
I just did it.
我刚刚做完。
It took me 10 minutes from error to success.
我从错误到成功花了 10 分钟。
回答by kris
XCode 6.1.1, and multiple apple developer accounts
XCode 6.1.1,以及多个苹果开发者账号
Another answer for this already fairly comprehensive mix: I came across this issue again today, and this time it was due to my having multiple apple accounts. I needed to first add the 2nd developer account in XCode > Preferences > Accounts > +
这个已经相当全面的组合的另一个答案:我今天再次遇到这个问题,这次是因为我有多个苹果账户。我需要先在XCode > Preferences > Accounts > + 中添加第二个开发者帐户
Ensure that the Push Notification Capability is ON
确保推送通知功能开启
Next I needed to actually explicitly enable In-App Purchase in the app (I did not need to do this previously). XCode > (the app window) > Targets > Capabilities > In-App Purchase ON(and at this stage I was given the option to choose the correct certificate)
接下来,我需要在应用程序中实际明确启用应用内购买(我以前不需要这样做)。XCode >(应用程序窗口)> Targets > Capabilities > In-App Purchase ON(在这个阶段我可以选择正确的证书)
Note that I had already added the Push enabled certificate by double clicking it in Finder.
请注意,我已经通过在 Finder 中双击它添加了启用推送的证书。
回答by ?mer Faruk Almal?
(Xcode 5) Well, after spending an hour I solved my issue. Even if you re-generate the provisioning file in Xcode 5, you should manually update your account. I only changed provisioning file in the Organizer tab that did not work, Xcode kept build with old provisioning file.
(Xcode 5)好吧,花了一个小时后我解决了我的问题。即使您在 Xcode 5 中重新生成配置文件,您也应该手动更新您的帐户。我只更改了无效的 Organizer 选项卡中的配置文件,Xcode 继续使用旧的配置文件进行构建。
So go to
所以去
Xcode > Preferences > Accounts > View Details (Select your account)
Xcode > Preferences > Accounts > View Details(选择你的账户)
Then refresh your provisioning files.
然后刷新您的配置文件。
回答by Graham Perks
My problem was simply that I was signing with the Xcode-managed wildcard provisioning profile.
我的问题只是我正在使用 Xcode 管理的通配符配置文件进行签名。
After I created an app-specific profile (and downloaded it, double-clicked it, and ensured my Build Settings referred to it), I successfully received an APNS device token.
在我创建了一个特定于应用程序的配置文件(并下载它,双击它,并确保我的构建设置引用了它)后,我成功地收到了一个 APNS 设备令牌。