Once you’ve generated XCode archive (make sure you are using valid provisioning profile and code signing identities), you can use following command to generate iPA file.
xcodebuild -exportArchive -archivePath $projectname.xcarchive -exportPath $projectname -exportFormat ipa -exportProvisioningProfile “Provisioning Profile Name”
xcodebuild – is the command.
-exportArchive is an argument to specify type of export
-archivePath is an argument to specify path of the xcode archive
-exportPath to specify path to export.
-exportFormat – one should keep it ipa (as our primary focus in this post is to generate iPA)
-exportProvisioningProfile – Keep it as it is being displayed under developer.apple.com/iphone