Xcode 3.2 provides an awesome new feature under the Build menu, \"Build and Archive\" which generates an .ipa file suitable for Ad Hoc distribution. You can also open the O
With Xcode 4.2 you can use the -scheme flag to do this:
xcodebuild -scheme archive
After this command the Archive will show up in the Xcode Organizer.