xcode 添加授权文件

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

Adding entitlement file

iphoneobjective-cxcodecocoa-touch

提问by Illep

I need to submit my app to the App Store. So before I do this, I validated my application using Xcode'svalidate process.

我需要将我的应用程序提交到 App Store。所以在我这样做之前,我使用Xcode's验证过程验证了我的应用程序。

When submitting for Validation, it required a entitlementfile to be added to the project. I was unable to create this file so I dragged an entitlementfile from another project and included in mine. This entitlementfile did not contain any data in it (it was an empty file). However when I submitted it to validation through Xcode the validation passed successfully.

提交验证时,需要将entitlement文件添加到项目中。我无法创建此文件,因此我entitlement从另一个项目中拖出一个文件并将其包含在我的项目中。该entitlement文件中不包含任何数据(它是一个空文件)。但是,当我通过 Xcode 将其提交到验证时,验证成功通过。

What I want to know is, What does a entitlementfile do (since the entitlementfile included in my project is empty) and will my app get rejected from appStore for dragging and dropping an entitlementfile from another project?

我想知道的是,entitlement文件有什么作用(因为entitlement我的项目中包含的文件是空的),我的应用程序是否会因为entitlement从另一个项目拖放文件而被 appStore 拒绝?

回答by Phradion

According to Apple Reference

根据苹果参考

Entitlements confer specific capabilities or security permissions to your app.

权利授予您的应用程序特定的功能或安全权限。

Specifically

具体来说

Set entitlement values in order to enable iCloud, push notifications, and App Sandbox (App Sandbox is Mac OS X only). Each entitlement has a default value, which in most cases disables the capability associated with the entitlement. When you set an entitlement, you are overriding the default by providing an appropriate key-value pair

设置权利值以启用 iCloud、推送通知和 App Sandbox(App Sandbox 仅适用于 Mac OS X)。每个权利都有一个默认值,在大多数情况下,该值会禁用与权利关联的功能。设置权利时,您将通过提供适当的键值对来覆盖默认值

  1. Entitlement file is just a plist file, you can see it as another setting file that include a few highlevel configuration and is essential for code-signing an adhoc build prior to xcode 4.x

  2. Empty entitlement file is valid as XCode will treat empty entitlement file as you want to use all the default value specified by Apple's reference. Leaving an entitlement file in your app project won't cause any harm, unless you specify something that your app is not capable of , i.e. icloud storage. Better to just delete that file if you don't need local distribution. :)

  1. 权利文件只是一个 plist 文件,您可以将其视为另一个设置文件,其中包含一些高级配置,对于对 xcode 4.x 之前的临时构建进行代码签名至关重要

  2. 空授权文件是有效的,因为 XCode 会将空授权文件视为您要使用 Apple 参考指定的所有默认值。在您的应用程序项目中保留授权文件不会造成任何危害,除非您指定了应用程序不具备的功能,即 icloud 存储。如果您不需要本地分发,最好只删除该文件。:)

According to Apple Technical Note TN2250(I recommend you to get rid of the entitlement file)

根据Apple Technical Note TN2250(我建议您去掉授权文件)

If you are defining a custom Code Signing Entitlements file within your Target > Build Settings, you might try removing that configuration entirely and rebuilding/resubmitting. More often than not, Code Signing Entitlements are defined unnecessarily. You only need to specify a custom Code Signing Entitlements file if your application is utilizing custom keychain access sharing or iCloud. Otherwise, remove the Code Signing Entitlements configuration from all build configurations on your Xcode project's Target > Build Settings, the rebuild and reattempt your submission/validation.

Specifying a code signing entitlements file unnecessarily is the most likely cause of errors such as -

The app 'Foo' was not installed on the iPhone "foobar's iPhone" because the entitlements are not valid.

In most cases, those entitlements seen above should be the only entitlements in your App's Signature. Applications using Apple Push Notification or iCloud will add a couple entitlements. Otherwise, extra entitlements than those listed above, or improperly spelled, or formatted versions of those entitlements will likely result in "failed codesign verification" preventing upload to the store, or for Ad Hoc builds produce the iTunes installation error 'the application was not installed because the entitlements are not valid'.

如果您在 Target > Build Settings 中定义自定义代码签名权利文件,您可以尝试完全删除该配置并重新构建/重新提交。通常情况下,代码签名权利的定义是不必要的。如果您的应用程序使用自定义钥匙串访问共享或 iCloud,您只需指定自定义代码签名权利文件。否则,从 Xcode 项目的 Target > Build Settings 上的所有构建配置中删除 Code Signing Entitlements 配置,重新构建并重新尝试提交/验证。

不必要地指定代码签名权利文件是导致错误的最可能原因,例如 -

应用程序“Foo”未安装在 iPhone“foobar's iPhone”上,因为权利无效。

在大多数情况下,上面看到的那些权利应该是您应用程序签名中的唯一权利。使用 Apple 推送通知或 iCloud 的应用程序将添加一些权利。否则,除了上面列出的那些额外的权利,或者这些权利的拼写不正确或格式化的版本可能会导致“失败的协同设计验证”阻止上传到商店,或者对于 Ad Hoc 构建会产生 iTunes 安装错误“应用程序没有安装因为权利无效”。

Please see Reference

请参阅参考