简体   繁体   中英

iOS: specify code signing identity with .xcconfig file

I'm working on an iOS application within a team of several developers. 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. 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.

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. 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. However, I haven't been able to write an .xcconfig file that solves the code signing entity issue. I tried to put the following line in my .xcconfig file:

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. 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.

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.

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.

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. This is what we do for our internal build system

Specify a profile with:

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

where the long hex number is the UUID of the profile. 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

UUID
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.*

CODE_SIGN_IDENTITY = iPhone Developer: Firstname Name (XXXXXXXXXX)

Try this for CODE_SIGN

Then go to "Build settings" => "Code signing" => "Provisioning profile" => "Left mouse button click" => Select "Other..." => enter "$(inherited)" => Enjoy!

在此输入图像描述

Please tell me if something doesn't work for you. Hope it helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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