Xcode bot stuck using old provisioning profile

Hi, a few weeks ago a bot I have for archiving builds had a certificate expire. I got everything updated with a new cert, and as part of that added the iCloud capability to the app. But now, the bot appears stuck using the old provisioning profile, and despite many attempts of everything I can think of, it just will not use an updated profile. So, the bot fails because it claims the profile doesn't have the iCloud capability.


This stack overflow post actually completely matches my problem:

https://stackoverflow.com/questions/47095706/xcode-server-xcode-9-uses-an-old-provisioning-profile?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa


Sadly, when I try the dirty hack suggested, the bot does finally start compiling the app, (it would fail instantly when starting to build the app previously), but fails at the export archive stage with an error about not finding the provisioning profile.


In the meantime, I've been manually archiving builds with Xcode on the same machine and uploading to iTunesConnect, but the bot is preferrable for many reasons. I'm exclusively using automatic code signing. I have other bots for other apps that are running just fine. All versions of macOS/Xcode are updated to the current versions.


When I look at the provisioning profiles in the Xcode server account, at `~/Library/MobileDevice/Provisioning Profiles`, it still has the old provisioning profile from before the cert expired there, and it's the only profile in that folder that corresponds to the app. If I move the profile out of that folder and try the bot, the error for the bot changes from not having the iCloud capability to not being found, so I'm confident that the server is still trying to use it, despite it being expired and out of date. It doesn't attempt to download a new version of the profile. And in the code signing section when editing the bot, it shows the new provisioning profile as being added to the server already.


Is anybody aware of any possible workarounds? Or is my solution to start over and reinstall macOS?


Thanks in advance for any help anybody could provide