How to export an IPA with Xcode Cloud

Hello. I'm using XCode Cloud to replace an existing fastlane workflow where the end result is to post an IPA to in internal Slack channel. I've written a ci_post_xcbuildscipt.sh and it runs:

xcodebuild -exportArchive -archivePath ${CI_ARCHIVE_PATH} -exportPath ${EXPORT_PATH} -exportOptionsPlist ${EXPORT_OPTIONS} -authenticationKeyIssuerID ${AUTH_KEY_ISSUER_ID} -authenticationKeyID ${AUTH_KEY_ID} -authenticationKeyPath ${AUTH_KEY_PATH} -allowProvisioningUpdates

My problem is resigning the IPA with the environment variables set as secrets. The autenticationKeyPath expects to be a file, but I'm only able to pass strings as environment variables.

I tried passing the key as a string and in my script writing it to a file, but the result is always an empty file. I've tested locally and this idea works, so I think it's a consequence of how the environment variables are protected when marked as a secret.

Any suggestions on how I could successfully export my archive but keep the key a secret?

I'm making, for example, an export_options.plist file manually via script. that might help you to archive what you need. ci_post_xcodebuild.sh

echo "Creating .PLIST"
output_file="export_options.plist"
rm -rf $output_file
plist_content="<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">
<plist version=\"1.0\">
<dict>
    <key>method</key>
    <string>app-store</string>
    <key>provisioningProfiles</key>
    <dict>
        <key>com..xxxxxxxx</key>
        <string>match AppStore com.xxxxxxxx</string>
    </dict>
    <key>teamID</key>
    <string>xxxxxx</string>
</dict>
</plist>"
echo "$plist_content" > "$output_file"

Could you please tell how you've managed to make an archive? my code is not working:

xcodebuild archive -project MyProject.xcodeproj -scheme MyProject -archivePath MyProject.xcarchive

gives me in console of Xcode Cloud:

/Volumes/workspace/repository/MyProject.xcodeproj: error: No signing certificate "iOS Development" found: No "iOS Development" signing certificate matching team ID "xxxxx" with a private key was found. (in target 'MyProject' from project 'MyProject')

turned out you can access the .IPA with:

cd $CI_APP_STORE_SIGNED_APP_PATH
ls -lh

in ci_post_xcodebuild.sh file

How to export an IPA with Xcode Cloud
 
 
Q