Is there a way to run the xcode > Product > Archive from the command line?

I’m automating some build stuff on my Mac and would really like a procedure to start the Product > Archive Ad-Hoc Xcode operation from command-line.

Something like ionic build ios --ad-hoc would be great.

Is there currently any way to do this? Seems like it should be possible given the Xcode command line tools.

Thank

Yes here is the script I use to auto deploy. The command you are looking for though is:

/usr/bin/xcodebuild archive   \
    -project MyApp.xcodeproj  \
    -scheme MyApp             \
    -archivePath MyApp