Since Xcode 9, Apple provides automatic code signing identity management from the command line by using the xcodebuild command.
Using the “allowprovisioningupdates” flag, you can enable code signing; however you may get errors like:
- Your session has expired. Please log in.
- The operation couldn’t be completed. Unable to log in with account
- There are no accounts registered with Xcode. Add your developer account to Xcode
- No profiles for ‘ID’ were found: Xcode couldn’t find any iOS App Development provisioning profiles matching ‘ID’
Some possible solution points for the xcodebuild -allowprovisioningupdates error are as follows:
1. Access to the Apple Developer Account:
It’s likely that your machine cannot connect to the Apple Developer Portal for some reason such as internet connectivity problems or invalid Apple credentials. In such a case, you can check your connection to developer.apple.com and if it is working, make sure that your correct credentials are entered in the build machine.
2. Certificate type checks:
It is also possible that the certificate type is causing conflicts with the allowprovisioningupdates flag. This may happen with in-house/enterprise certificates. In such a case, you can try to change the certificate type or use another developer account with the App Store Distribution
Therefore the answer seems to be that we shouldn’t be using automatic signing for in-house/enterprise distibution, but instead only for App Store deployments.
3. Using a mobile CI/CD tool:
Actually, the best solution may to use a specialized tool for iOS CI and CD. Tools like Appcircle automate the full build and sign process in the cloud, even without the need for a Mac.
You can use the signing identities module in Appcircle to manage your iOS certificates and provisioning profiles centrally instead of depending on the automatic management provided by Apple.
4. If nothing else works, removing and readding the Apple Developer account may also work:
- Remove the developer account in the preferences section of Xcode
- Quit Xcode
- Launch the terminal and use the following command to set the preference to not use the keychain service:
defaults write com.apple.dt.Xcode DVTDeveloperAccountUseKeychainService_2 -bool NO
- Launch Xcode and readd the developer account