简体   繁体   English

iOS:使用.xcconfig文件指定代码签名标识

[英]iOS: specify code signing identity with .xcconfig file

I'm working on an iOS application within a team of several developers. 我正在一个由几个开发人员组成的团队中开发iOS应用程序。 We all have our developer certificates that belong to the same development provisioning profile. 我们都拥有属于同一开发配置文件的开发人员证书。 When I build the app we're working on in order to test it on a device, I need to specify explicitly the code signing identity to use. 当我构建我们正在处理的应用程序以便在设备上进行测试时,我需要明确指定要使用的代码签名标识。 Otherwise, If I select the automatic profile selector, I get a code signing mismatch error when uploading the app to services like HockeyApp. 否则,如果我选择自动配置文件选择器,则在将应用程序上载到HockeyApp等服务时会出现代码签名不匹配错误。 Indeed, when I select the automatic profile selector, it seems to select the iOS Team Provisioning profile instead of the development provisioning profile specific to the app that I'm building. 实际上,当我选择自动配置文件选择器时,它似乎选择了iOS Team Provisioning配置文件,而不是特定于我正在构建的应用程序的开发配置文件。

When I was the only developer of this application, I fixed this issue by hardcoding the right code signing entity to use in the build settings. 当我是这个应用程序的唯一开发人员时,我通过硬编码正确的代码签名实体来修复此问题,以便在构建设置中使用。 The problem is that I'm not the only developer on this project anymore. 问题是我不再是这个项目的唯一开发人员了。 The problem with hardcoding my code signing identity in my project settings is that I have to remove it every time I commit a change to the project's settings, or if I don't my teammates will get errors when they sign the app saying that the code signing identity can't be found on their computer. 在我的项目设置中硬编码我的代码签名身份的问题是,每次我对项目的设置进行更改时都必须删除它,或者如果我不这样做,我的队友在签署应用程序时会出现错误在他们的计算机上找不到签名身份。

So what I'm trying to do is to setup a .xcconfig file where each of the team members would specify what code signing identity to use. 所以我要做的是设置一个.xcconfig文件,其中每个团队成员都会指定要使用的代码签名标识。 This file would not be versioned so everyone could set their code signing identity explicitly without causing any issue for other developers within the same team. 此文件不会被版本化,因此每个人都可以明确设置其代码签名身份,而不会对同一团队中的其他开发人员造成任何问题。

I managed to include an .xcconfig file in my project and it is processed during the build phase. 我设法在我的项目中包含一个.xcconfig文件,并在构建阶段进行处理。 However, I haven't been able to write an .xcconfig file that solves the code signing entity issue. 但是,我无法编写解决代码签名实体问题的.xcconfig文件。 I tried to put the following line in my .xcconfig file: 我试着将以下行放在我的.xcconfig文件中:

CODE_SIGN_IDENTITY = iPhone Developer: Firstname Name (XXXXXXXXXX)

where Firstname Name (XXXXXXXXXX) is the result of copy/pasting the code signing identity I want to use from the build settings to the .xcconfig file. 其中名字名称(XXXXXXXXXX)是将我想要使用的代码签名标识从构建设置复制/粘贴到.xcconfig文件的结果。 I later realized that all my code signing identities for all my development profiles (one for each application or bundle identifier) give the same result when I copy/paste them from the build settings to the .xcconfig file. 我后来意识到,当我将它们从构建设置复制/粘贴到.xcconfig文件时,我所有开发配置文件(每个应用程序或包标识符一个)的所有代码签名标识都会产生相同的结果。

I was looking for a way to differentiate them, but I didn't manage to find one that works. 我一直在寻找一种区分它们的方法,但我没有找到一种有效的方法。 Do you have any idea of how I could solve this problem ? 你知道我怎么能解决这个问题吗?

I also tried using the [sdk=iphoneos*] modifier, with no success. 我也尝试使用[sdk = iphoneos *]修饰符,但没有成功。

I would like to avoid using different build configurations because I feel that I would have to merge changes made to the main configuration to a new build configuration that would be made just for the purpose of using the right code signing identity. 我想避免使用不同的构建配置,因为我觉得我必须将对主配置所做的更改合并到一个新的构建配置中,该配置只是为了使用正确的代码签名标识。 However, I'm not familiar with how build configurations work within XCode, so feel free to educate me on that if you think it could be a good solution. 但是,我不熟悉构建配置如何在XCode中工作,所以如果您认为它可能是一个很好的解决方案,请随时教我。

Thank you! 谢谢!

Instead of selecting the CODE_SIGN_IDENTITY, which ultimately doesn't matter, you could instead specify the PROVISIONING_PROFILE and leave Xcode to sign it with whatever identity matches. 您可以改为指定PROVISIONING_PROFILE,而不是选择最终无关紧要的CODE_SIGN_IDENTITY,并让Xcode使用任何标识匹配对其进行签名。 This is what we do for our internal build system 这就是我们为内部构建系统所做的工作

Specify a profile with: 指定配置文件:

PROVISIONING_PROFILE=cb65516b-ee34-4334-95d6-6fba5f2df574 PROVISIONING_PROFILE = cb65516b-ee34-4334-95d6-6fba5f2df574

where the long hex number is the UUID of the profile. 其中长十六进制数是配置文件的UUID。 If you look inside a provisioning profile you'll find that most of it is ASCII, even though it's a binary file, and it has a section like this 如果您查看配置文件,您会发现大部分是ASCII,即使它是一个二进制文件,它有一个这样的部分

UUID UUID
395525c8-8407-4d30-abbd-b65907223eec 395525c8-8407-4d30-abbd-b65907223eec

We have this working (so do others ). 我们有这个工作( 其他人也这样)。 Don't the include the part between the braces, just the name part in front of it. 不要包括大括号之间的部分,只是它前面的名称部分。 If you need to differentiate, I'd recommend to name your identities differently (eg by including a reference to the customer or project name you're using the identity for). 如果您需要区分,我建议您以不同方式命名您的身份(例如,通过包含对您使用身份的客户或项目名称的引用)。

Just add this to xcconfig.* 只需将其添加到xcconfig。*

CODE_SIGN_IDENTITY = iPhone Developer: Firstname Name (XXXXXXXXXX) CODE_SIGN_IDENTITY = iPhone开发者:名字名称(XXXXXXXXXX)

Try this for CODE_SIGN 试试这个CODE_SIGN

Then go to "Build settings" => "Code signing" => "Provisioning profile" => "Left mouse button click" => Select "Other..." => enter "$(inherited)" => Enjoy! 然后转到“构建设置”=>“代码签名”=>“配置文件”=>“鼠标左键单击”=>选择“其他...”=>输入“$(inherited)”=>享受!

在此输入图像描述

Please tell me if something doesn't work for you. 如果有什么不适合你,请告诉我。 Hope it helps. 希望能帮助到你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM