I have an Ionic 5/Angular iOS app which builds fine as a non-production build and runs on both emulator and device as a dev build.
When I come to build it as a production build using:
ionic cordova build --prod --device
I use the ionic cordova build --prod command with the --device param to build the final IPA.
The app bundle Archive succeeds (so I can get an APP file), but the final stage fails with:
Error Domain=IDEProvisioningErrorDomain Code=9 ""blah.app" requires a provisioning profile with the Associated Domains feature." UserInfo={IDEDistributionIssueSeverity=3, NSLocalizedDescription="blah.app" requires a provisioning profile with the Associated Domains feature., NSLocalizedRecoverySuggestion=Add a profile to the "provisioningProfiles" dictionary in your Export Options property list.}
However, the identifier for the app has the associated domains entitlement selected and the provisioning profile in Xcode confirms this. Even a quick-look on the file itself shows the entitlement to be present:
I’ve searched for help with this, but there appears to be nothing specifically like this, where a build is failing because the system says an entitlement isn’t there, when it actually is.
I’ve tried redoing all of the signing from scratch, to no avail.
Has anyone seen/fixed this before, and if so, what did you do? Tearing my hair out.
Has anything changed since the last time you built for production? The app itself, an Xcode upgrade, certificate expired, etc? That might lead you down the path to a fix. Otherwise…
Some steps to try:
Check Apple Developer site → Provisioning Profile, ensure that Associated Domains is checked on, like here.
in Xcode, under Associated Domains, ensure that the Domain(s) is set.
Review the Ionic CLI docs for cordova build. Is that the exact command you’ve used successfully in the past? Maybe you need the --release flag?
Xcode has been upgraded, probably a few times, since the last release.
I’ve completely wiped, done and redone the whole certificate, app ID (which does have the Associated Domains tick) and provisioning profile thing more than once now. Xcode also shows the associated domain under the Signing and Entitlements section.
Regardless of using --release or --device, the build still fails at that last step. It fails on both my M1 Mac Mini and my Intel Macbook Pro. In the past, it was the --device command which was successfully used in the past.
So, a solution of sorts has been found. I had originally tried this, allowing Xcode to manage the profiles and although this allowed the IPA to build, the resultant IPA had an integrity issue which, no matter how I cleared down the profiles and certificates, etc. I just couldn’t get this IPA to work. This was the issue, which must be indicative of something else, because the app did have profiles, certificates and an appropriately entitled app id:
However, after exhausting all options, I literally did one final cleardown of the profiles and certificates, and started all over again with them (again, again), I finally got the:
ionic cordova build ios --prod --device
command to create an IPA using the Xcode managed profile and it worked with no integrity issues.
I don’t recall having to do things using Xcode managed profiles previously, but at least I can move forward with this.