My name is Luca and I am currently working on iOS continuous integration to build apps in xcode for distribution (Ad Hoc and App Store) using shell-scripting.
So fa
this may be too late for the original poster, but may help others. for my build process, i use xcodebuild to with first clean and then build, then i use xcrun to create the archive:
/usr/bin/xcrun -sdk iphoneos PackageApplication -v "build//.app" -o ".ipa" --sign "" --embed ".mobileprovision"
with this command, i can create an archive for the app store, or even upload an ad-hoc build to TestFlight like this:
curl http://testflightapp.com/api/builds.json \
-F file="" \
-F api_token='' \
-F team_token='' \
-F notes='Automated build' \
-F notify=True \
-F distribution_lists='me'
this works as of xcode 6.1