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/'
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?


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.