Resolving Duplicate Profiles Error in Fastlane match for iOS
#swift
#native
#iOS
#match
#fastlane
#CI
#react native
While working on automating iOS builds using Fastlane, I encountered an issue related to code-signing profiles managed by
match
. The error message was as follows:multiple profiles found with the name match 'match AppStore xxx.xxx.xxx'. Please remove the duplicate profiles and try again
This error indicates that multiple profiles with the name
match AppStore xxx.xxx.xxx
exist, and Fastlane was unable to resolve which one to use.Upon investigation, it seemed like the profile name serves as a unique identifier for the profile, so having duplicate profiles with the same name would lead to conflicts.
Initially, I considered two possible solutions:
1. Delete the duplicate profiles using match nuke
or manually remove them via the Apple Developer portal.
2. If that didn't work, bypass the issue by using cert
and sigh
to manually manage the certificates and profiles.
However, both of these solutions didn't work for the following reasons:
- Even though I logged into the Apple Developer portal with our company's account, I couldn't find a profile with the name
match AppStore xxx.xxx.xxx
. Despite searching, it seemed that the profile didn’t exist in the portal at all.
- While attempting to use
cert
andsigh
in a GitHub Action workflow, I faced practical limitations that made this solution less feasible.
After some trial and error, I discovered a workaround using Fastlane's
match
to specify a custom profile name, avoiding the need to rely on the default name match AppStore xxx.xxx.xxx
.Here’s how you can fix this issue:
Step-by-Step Solution
1. (Optional) Delete the Existing Profile Using match nuke
First, you can try deleting the existing profile using
match nuke
if it's visible in your developer account. This step is optional and can be skipped if the profile doesn't exist.match_nuke( type: "appstore", api_key: app_store_connect_api_key, # Fastlane's app_store_connect_api_key username: "apple developer account email", # Apple developer account email app_identifier: "bundle id", # Your app's bundle ID profile_name: "match AppStore xxx.xxx.xxx" # (Optional) Profile name to delete )
2. Create the Profile on the Apple Developer Portal
Now, create the provisioning profile manually on the Apple Developer portal using Fastlane's
get_provisioning_profile
action. This action will allow you to create the profile with a custom name instead of relying on the default match
naming convention.get_provisioning_profile( development: false, # Set to true for development profiles force: true, team_id: "apple developer team id", # Your Apple Developer team ID filename: "xxxxxx.mobileprovision", # The name for your provisioning profile provisioning_name: "custom AppStore xxx.xxx.xxx" # Custom name for your profile )
Make sure that the profile you create has the correct distribution certificate associated with it. If the certificate is set to "iOS Distribution" in the Apple Developer portal, make sure it's correctly linked to Xcode and set to distribution.
3. Link the Custom Profile to GitHub Repo Using match
Now, use
match
with the custom profile name to link it to your GitHub repository. This will allow you to use your custom provisioning profile in your automated build pipeline.match( git_url: "<https://github.com/user-name/repo-name>", # URL of the GitHub repo where certificates are stored storage_mode: "git", type: 'appstore', app_identifier: "xxx.xxx.xxx", # Your app's bundle ID readonly: false, # Set to false to allow updates to the repo verbose: true, api_key: app_store_connect_api_key, # Your App Store Connect API key profile_name: "custom AppStore xxx.xxx.xxx" # Custom profile name you created )
Conclusion
With these steps, you can link your custom provisioning profile to your GitHub repo and bypass the issue of having duplicate profiles. By setting the
profile_name
parameter in match
to a custom value, you no longer need to rely on the default match AppStore xxx.xxx.xxx
name, resolving any conflicts.This approach also gives you more flexibility in naming your profiles and avoiding the issues that arise from duplicate names.