Search code examples
iosreact-nativecommand-line-interfaceprovisioning-profilexcodebuild

xcodebuild does not recognize provisioning profiles


I am trying to build and publish a react native iOS app on Testflight through the Xcode CLI. I manage to build and publish the application through Xcode GUI, but I cannot do the same using Xcode CLI. After the archive is created with xcodebuild, I'm getting an error for provisioning profiles even though I've checked that they've all been installed and already exist. I am using MacBook Pro PC, macOS Ventura 13.1 and Xcode 14.2.

ERROR:

Error Domain=IDEProfileLocatorErrorDomain Code=4 "No "iOS App Store" profiles for team 'xxxxxxxxxx' matching 'test-profile' are installed." UserInfo={IDEDistributionIssueSeverity=3, NSLocalizedDescription=No "iOS App Store" profiles for team 'xxxxxxxxxx' matching 'test-profile' are installed., NSLocalizedRecoverySuggestion=Install a profile (by dragging and dropping it onto Xcode's dock item) or specify a different profile in your Export Options property list.}

I use the sample app [https://github.com/croma-app/croma]), which I successfully built through Xcode 14.2, and then created an archive, which I can export as an .ipa file or upload to Testflight directly. Xcode succeeds in signing and exporting the archive, while the xcodebuild CLI fails.

xcodebuild command:

user@SPARE-WSM-xxxxxxxxxxxx ios % sudo xcodebuild -exportArchive -exportOptionsPlist ExportOptions.plist -archivePath croma.xcarchive -exportPath '/ipa/'
  • I double checked that the ExportOptions.plist is identical to the archive created by Xcode.
  • Xcode recognizes the iOS App Store distribution "test-profile" while xcodebuild does not.
  • "test-profile" is installed and located at '/Users/user/Library/MobileDevices/Provisioning Profiles/f5de3135-6ffa-4834-9f61-be39a178e284.mobileprovision'.
  • Also, inside the ExportOptions.plist file I used the UUID "f5de3135-6ffa-4834-9f61-be39a178e284" and "f5de3135-6ffa-4834-9f61-be39a178e284.mobileprovision'" instead of the name "test-profile".
  • Automatically manage signing did not help, xcodebuild CLI still does not recognize the profile.
  • Downgrading Xcode version to 14.1 didn't help either. -I also tried unlocking the keychain although using sudo, but the error is still the same.
security unlock-keychain -p 'xxxxxxxx' /Users/user/Library/Keychains/login.keychain-db

I believe that it is a small problem with the user's permissions and his access to provisioning profiles files. But how can I fix it?

  • How can I verify that 'Library/MobileDevices/Provisioning Profiles/' is the correct location where xcodebuild is looking for provisioning profiles?

Solution

  • SOLVED!

    After I started the xcodebuild archive command without "sudo", I realized that I was getting some other error. I was able to solve that error, as well as others, because I was getting a clearer error message. In the end I was able to archive and upload the app to Testflight through the xcodebuild CLI.

    I tried the same process once again using "sudo", but I still get the same error. I think xcodebuild does not work as expected when using "sudo". Since I spent a lot of time trying to figure out the cause of the problem, I would suggest avoiding using "sudo" in this case.