Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

xcodebuild archive path of newly created archive

When I archive from the command line using xcodebuild archive, how can I get the path to the newly created archive? I'd like to follow on with an -exportArchive command to create an adhoc distribution.

I know that I can define an -archivePath, however if I do that then Organizer doesnt know where about this archive, so that's no good.

Thoughts?

like image 461
toofah Avatar asked Jun 07 '17 17:06

toofah


People also ask

Where are Xcode Archives stored?

Xcode created your archive. The actual . xcarchive folder resides on your Mac in ~/Library/Developer/Xcode/Archives.

Where can I find Xcarchive?

The . xcarchive will be placed in the $HOME/Library/Developer/Xcode/Archives directory on the Mac build host that both Xcode and Xamarin Studio search to display previously built archives. See the documentation about Xamarin.

How do I open Archives organizer?

The Archives organizer is a pane in the Organizer window that you use to upload your app to App Store Connect. To open the Archives organizer, choose Window > Organizer and click Archives. To complete the upload of your app to App Store Connect, click the blue Upload to App Store button.

Do I need to build before archive Xcode?

Make sure your build is successfulBefore beginning to archive your build, you need to make sure that the build is successful not only for Debug, for also for Release. Remember to test thoroughly with different types of scenarios to make sure there's no crash or bug.


2 Answers

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!

like image 62
Danny Yassine Avatar answered Sep 19 '22 08:09

Danny Yassine


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}).

like image 43
Yousef Hamza Avatar answered Sep 18 '22 08:09

Yousef Hamza