xcodebuild archive path of newly created archive

you can simply create a variable holding the path of the archive you want to generate. Then use the same path when you want to export

$ARCHIVE_PATH="<path_of_your_archive>" # can be something like "build/app_name.xcarchive"

# ARCHIVING

xcodebuild archive \
    -workspace "${APP_NAME}.xcworkspace" \
    -configuration $CONFIGUATION \
    -scheme $SCHEME \
    -archivePath $ARCHIVE_PATH

# EXPORTING

xcodebuild -exportArchive \
     -archivePath $ARCHIVE_PATH \
     -exportPath $OUTPUT_DIRECTORY \
     -exportOptionsPlist exportPlist.plist

Hope this helps you in any way!


There's $ARCHIVE_PATH variable that's only available in archive post-actions scriptsenter image description here

Edit: $ARCHIVE_PATH returns a kind of generic path that doesn't account for the date, time, or duplicate suffixes.

Use $ARCHIVE_PRODUCTS_PATH instead. Or actually REAL_ARCHIVE_PATH=$(dirname ${ARCHIVE_PRODUCTS_PATH}).