Update a provisioning profile using App Store Connect API. How? - ios

I would like to re-generate a set of provisioning profiles using App Store Connect API.
There are methods for creating new profiles, deleting existing, but I see no method to update profiles.
Is anyone aware of such a method?
The need to regenerating is that there is a big number of these profiles and I need to update the profiles preserving all the information but the certificate, which is going to expire soon.
It is possible to regenerate manually in the console, but I would prefer a pretty small script for this.
Thank you in advance.

The api doesn't support editing or updating a provisioning profile as far as I am aware.
Instead it is possible to get the details from the old provisioning profile then make a new provisioning profile with those details. Then delete the old profile.
You'd need to give it a new name, I'd personally either use a number or an alternating pattern at the end of the provisioning profile name to ensure Apple unique name constraint is upheld.

Related

Provisioning Profiles was invalid but Certificate and App ID are valid, why is that

My provisioning profile suddenly became invalid.
I logged in developer.apple.com couples of days ago and everything was fine. Today I logged in again and was surprised to find that both of my development profile and distribution profile were invalid. The certificates and App ID are valid, I did not revoke any of them and they are not expired at all. So why my profile became invalid?
I know I can re-generate profile but because I do enterprises distribution not app store distribution. I am worried that regenerating profile may affect current users. Also, I really need to figure out the reason to prevent it from happening again.
Any idea? Thanks!
Updated: First of all, it is not because the profiles were expired, their expiration date is at the end of 2015.
Second, I did re-generate development profile at morning but I just checked it and found the profile was invalid again! Something weird must happen and I have submitted a support ticket to apple and wait for their response.
I'm curious to see what Apple support says. According to Apple (https://developer.apple.com/library/ios/qa/qa1878/_index.html) :
Q: What causes the provisioning profile "Invalid" status? How do I resolve it, and how do I prevent it?
A: The provisioning profile invalid status is caused by changes to the profile’s associated certificate or App ID. Any time an App ID or certificate changes, all profiles that are associated to it are marked Invalid. This does not apply to Xcode's team profiles, but applies to all profiles that Xcode does not manage, specifically, custom development profiles and distribution profiles. This document explains the causes in detail and provides steps to resolve and avoid the profile invalid status.
One possibility is that you modified the app id by turning on or off services in Xcode:
Avoidance
Since Xcode started managing services on App IDs (through the Xcode >
Target > Capabilities tab), Invalidating provisioning profiles became
as easy as enabling or disabling a target capability. Remember that
every time the App ID changes with respect to its enabled services,
all profiles attached to that ID become invalid.
Hope this helps.
It seems that somebody still hits this problem after almost a year when I first raised it. So I am answering my own question trying to provide some insight.
Apple never answered my ticket instead they returned my credit. I took that as a sign that they had no idea either (saw my comments above). I can still use that "invalid" profile but it really made me uncomfortable. So I created a different one.
In summary it maybe just a bug in their system and if you have tried all the solutions and the problem still exists just create a new one.
If you generate a new provisioning profile, your old installations (store or adhoc) won't be affected
The provisioning profile lives for 1 year, maybe it expired so simply remove it and make another one with the same certificates, app ids and devices and you can use it without any problem
EDIT:
I don't know a case where a provisioing profile would become invalid unless:
It reached its expiry date;
You modified the app id or certificates that are related to it.
I guess it's related Automatically manage signing in Xcode. In case you switch to another branch which has different configures in Xcode > Target > Capabilities, Xcode will change your App ID settings
If you generate a new CSR for something like an APNS certificate, it will mark your provisioning profiles as invalid.
Guess I found the answer, it's simple go to the apple developer account and select those certificates which wasn't working.
1.Edit them and simply add some new name just to remember.
Select same App Id and certificate for both development profile and distribution profile and hit the download button
After downloading add them into you Xcode and you will them there.
it generally happens when you update your Xcode, so be sure when you check certification where Xcode is mentioned(For use in Xcode 11 or later in my case)
For me it's just opening the apple developer account, edit the profile, save it and download the provisioning. Made a new build and then reupload it.

Wildcard provisioning profiles conflict in Xcode with multiple Apple IDs

I have several accounts configured in Xcode under Preferences/Accounts and I use Xcode to generate certificates.
It generated a wildcard provisioning profile for all the accounts I have, with the name iOS Team Provisioning Profile: * but I can't find a way to choose which client's wildcard profile do I want to use because I have different certificates for all of them and I'd like to use the appropriate profile with the right account for each client. Now I only see the one that was last updated.
Does anybody know how to solve this?
If you have some 3rd party plugins or any other tricks/hacks I'd more than love to hear those.
No I don't think you can do anything about this, Its happening to me too, Xcode takes the WildCard ID of the Last updated Account which you add, If you want to use a Specific account to sign your app with you would have to use the developing Profile corresponding to your bundle ID, which are generated by Xcode automatically

Certificate identity 'iPhone Developer: ' appears more than once in the keychain. The codesign tool requires there only be one

Ok, I am completely pulling my hair out on this one.
Back in July I created a provisioning profile so I could test on my iPad.
Then at the end of August I tried submitting my first App to the iTunes Store. The process was a complete nightmare, and I struggled. A lot. In the end I found a tutorial with relatively recent information in it, and only by following it step by step could I actually get anywhere with this. Unfortunately the result of this was that I created a new provisioning profile.
Now when I try to test on my iPad I get the following error in Xcode:
Certificate identity 'iPhone Developer: MyName' appears more than once in the keychain. The codesign tool requires there only be one.
I check the keychain, and sure enough there are the two provisioning profiles for development, one from July and the one I used to submit to the iTunes Store in August.
Now what I want to do is get rid of the old one, and then connect my iPad up to the new one. I can get rid of the old one fine, but I cannot connect my iPad to the new one, it insists on using the old profile, even to the point of re-attaching it to the keychain after Ive deleted it.
Can anyone tell me:
How to connect my iPad to the new provisioning profile?
And while we are at it, can anyone shed any light on why this entire process is so convoluted and difficult? Considering that so much of Apples interface is so well designed and fluid, this process of registering certificates and applying them to different devices and Apps seems so backwards. I initially suspected this was just me, but googling for these error messages reveals that there are many who are struggling at various points along this process.
This has nothing to do with Xcode and everything to do with keychain.
Open keychain.
Find the signing certificates that are tied to your provisioning profiles.
Delete one. You probably want to keep the newer one, so look at the expiration dates and remove the one that expires first.
Restart Xcode
You may need to update your provisioning profile if it isn't tied to the new certificate, but it won't be as painful as creating a new certificate.
Here's a broad overview of how code signing in Xcode works. It a bit much but will explain what's wrong with your configuration, and how you can fix it.
There are three parts to the mechanism that ensures that you are who you say you are and that your app is allowed to run where it wants to.
You've got a pair of keys, one public and one private. Your public key matches your private key, which identifies you.
Your keys are used to generate certificates. Generally, you'll have one certificate for development and one for distribution,either on the App Store or via Ad Hoc distribution. These certificates permit you to provision your apps.
Each certificate is used to generate provisioning profiles. The profiles must be attached to either a development or a distribution certification. A distribution profile either works on the App Store, or it contains a list of device IDs which may run apps signed with that profile.
If your certificate is expired, the provisioning profiles that are created with it are going to be invalid. In this case, replace both the certificate and the profiles. Generate a certificate signing request (CSR) from Keychain Access and upload it to the developer portal.
If you have multiple certificates in your keychain, Xcode won't know which one to use. This may happen if you renew your certificate and don't remove the old one. (It may also happen if you exported your developer profile and then imported it later. Your old certificates will carry over.)
If your provisioning profile is expired or invalid, you can renew it in the developer portal without generating a new CSR. You can just attach it to an existing valid certificate.
Certificates can't be carried over from one machine to another without moving the original key pair that requested it. Exporting the certificate from Keychain will export the keys as well.
Delete the old one, and start build with new.
One more way you can try , set code signing identity with profile you want to run in both target as well as project build setting.
Hope it will help you.
Otherwise you have to delete old one.

How to add a device to an existing Ad-Hoc Provisioning Profile?

Have just noticed that Apple redesigned iOS Dev Center this weekend.
I need to add a couple of devices to an existing Ad-Hoc provisioning profile. But when I push Edit button, I can change only Name and App ID.
Is it any way to do it except of the obvious one: to delete the existing profile and create a new one with all required devices?
UPD.
Now I can edit the list of devices for development profiles, but not for distribution.
UPD. 2
Can edit devices for new distribution profiles, but can't do it for old.
It Works!
Apple fixed it. So it was a bug. Now you can edit your embedded device list, even if it's an Ad Hoc distribution profile.
I looked into this on the forum and found a reference to the new App Distribution Guide. You need to delete your old profile and create a new one. You'll be given the choice at that time to add devices to the new profile. The feeling is that Apple has changed the format of the profile and this is a way of forcing you to recreate a new profile in the new format.
It seems you can't edit it (generate button isn't enabled) if for example you have underscores in the profile name.

modify provisioning profile from xcode 4

i have multiple provisionnig profile and in this times i have to add( and delete) devices, and this make me crazy, in fact i go to developer.apple.com and remove or add devices for those profiles, and i have to download it,add it to organizer ans delete the old ones otherwise i cant manage all of theme.
i look to xcode(4.3.2) and i see that i can add provisioning profile.
there is a way to MODIFY existing one ?
or can you tell me how you do in this cases ?
thank you.
No, the standard developer.apple.com is the only way. Apple adds a digital signature to the provisioning profile, so any modification made by anyone else invalidates it.

Resources