xcode 如何为不同的目标设置不同的 .entitlements 文件

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

How to set different .entitlements file for different targets

iosxcodetarget

提问by Viktor

I have 2 targets - Dev & Prod config with different capabilities (Apple Pay disabled for Prod)

我有 2 个目标 - 具有不同功能的 Dev & Prod 配置(Apple Pay 为 Prod 禁用)

I already have separated Info.plist files with needed target But I couldn't do same for Proj.entitlements files - Target Membership section in Utilities menu disabled

我已经将 Info.plist 文件与所需的目标分开但我无法对 Proj.entitlements 文件执行相同的操作 - 实用程序菜单中的目标成员资格部分已禁用

I set corresponding "Code Signing Entitlements" in Build Settings of each target, but still receiving "Provision Profile 'X' doesn't support 'X' capability" in General tab

我在每个目标的构建设置中设置了相应的“代码签名权利”,但在“常规”选项卡中仍然收到“配置文件‘X’不支持‘X’能力”

Is there any way to say XCode, that for this target he should look at connected .entitlements file?

有什么办法可以说 XCode,对于这个目标,他应该查看连接的 .entitlements 文件?

回答by Philipp Otto

I also tried to set separate entitlement files for my targets to activate push notifications only for some of my targets. Every time I changed the capabilities of one of my targets the changes were also applied to the other targets because XCode only edited the same entitlements file all the time although I set a different file path for each target in

我还尝试为我的目标设置单独的权利文件,以便仅为我的某些目标激活推送通知。每次我更改一个目标的功能时,更改也会应用于其他目标,因为 XCode 始终只编辑相同的权利文件,尽管我为每个目标设置了不同的文件路径

Build Settings > Code Signing Entitlements

For me the problem was that the entitlement files all had the same name. When I gave every target entitlement file an unique name XCode changed the correct files for the respective target.

对我来说,问题是权利文件都具有相同的名称。当我为每个目标授权文件指定一个唯一名称时,XCode 更改了相应目标的正确文件。

回答by ZeroOne

Go to Project> Target > Build Settings > Signing

转到项目>目标>构建设置>签名

Here in 'CODE_SIGN_ENTITLEMENTS', put your path.

在“CODE_SIGN_ENTITLEMENTS”中,输入您的路径。

$(SRCROOT)/ProjectName/PathToFolder/AnotherFolder/YourProject.entitlements

$(SRCROOT)/ProjectName/PathToFolder/AnotherFolder/YourProject.entitlements

Here in Debug and Release you can choose different path.

在 Debug 和 Release 中,您可以选择不同的路径。