Xcode 4.6 自动授权不起作用 - “没有有效的 aps-environment" [英] Xcode 4.6 automatic entitlement not working - "no valid aps-environment"

查看:59
本文介绍了Xcode 4.6 自动授权不起作用 - “没有有效的 aps-environment"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了著名的错误:
获取令牌失败,错误:错误域=NSCocoaErrorDomain Code=3000没有为应用程序找到有效的aps-environment"授权字符串" UserInfo=0x413be0 {NSLocalizedDescription=没有为应用程序找到有效的aps-environment"授权字符串}

我可以通过编辑以下文件来修复它:

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk/Entitlements.plist

并手动添加 aps-environment 密钥,如下所示:

And manually adding the aps-environment key like so:

<?xml version="1.0" encoding="UTF-8"?>
<!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>$(AppIdentifierPrefix)$(CFBundleIdentifier)</string>
    <key>aps-environment</key>
    <string>development</string>
    <key>keychain-access-groups</key>
    <array>
        <string>$(AppIdentifierPrefix)$(CFBundleIdentifier)</string>
    </array>
</dict>
</plist>

然后,Xcode 生成正确的 Xcent 文件,其中包含 aps-environment 密钥:

Then, Xcode is generating correct Xcent file, which contains the aps-environment key at:

/Users/mySelf/Library/Developer/Xcode/DerivedData/myApp-buauvgusocvjyjcwdtpewdzycfmc/Build/Intermediates/myApp.build/Debug-iphoneos/myApp.build/myApp.xcent

并且在 iPhone 上运行该应用程序能够生成用于推送的设备令牌.
这是我找到的解决问题的唯一方法.
(如果遇到此错误,您可以将此信息用于自己的故障排除)

And running the App on iPhone is able to produce device token for push.
This is the only way I found to fix the issue.
( you may use this info for your own troubleshooting in case you encounter this error )

现在,我在另一台笔记本电脑上运行了相同的项目(与 git 同步),
使用相同的 Xcode 版本 4.6.
该问题在该笔记本电脑上不会发生.
两台机器上的项目设置/配置文件等都是 100% 相同的.
(请相信我这一点)

Now, I have the same project running on another laptop (synced with git),
with the same Xcode version 4.6.
This problem does not occur on that laptop.
Project settings/provisioning profile,etc are all 100% the same on both machines.
( Please trust me on this one )

有人在使用 Xcode 4.6 时遇到过这样的问题吗?
我也应该在 Apple 的支持部门开一张票.

Did anyone encounter such issue with Xcode 4.6 ?
I should probably open a ticket at Apple's support as well.

只是想知道是否有其他更优雅的解决方案.

Just wondering if another more elegant solution is available.

上述修复仅适用于开发阶段,但不适用于发布.

The above fix could be sufficient only for devel stage but not for release.

推荐答案

覆盖默认 Entitlements.plist 的更优雅的解决方案是制作您编辑过的默认 Entitlements.plist 的副本,并将其放入您的项目中.

A more elegant solution for overriding the default Entitlements.plist is to make a copy of the default Entitlements.plist that you have editted, and put that in your project.

然后,为您遇到问题的任何目标构建设置代码签名权利(在本例中,我已将其设置为调试).

Then, set the Code Signing Entitlements for whichever target build you are having problems with (in this case I've set it for Debug).

这应该使用这个 plist 文件进行调试构建(即当简单地按下运行时),你的设备将注册到 APNs 开发服务器

This should then use this plist file for Debug builds (ie when simply pressing Run) and your device will register with the APNs development servers

这篇关于Xcode 4.6 自动授权不起作用 - “没有有效的 aps-environment"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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