Building iOS with Jenkins (spinning terminal window)

I am having trouble with building an .ipa file on a Mac system running Jenkins. My GIT project excludes the “platforms” folder so, after pulling code from GIT, I run

ionic platform add ios (succeeds)
ionic build ios (succeeds)

And finally this:
xcodebuild -scheme BestAppEver clean archive -archivePath build/BestAppEver

However, this last command results in a terminal window spinning forever with no end. This command DOES work if I open the generated .xcodeproj file first and then run the command in the terminal window. Has anyone seen this? Or have any ways around it?

This is because your sheme BestAppEver does not exist.
You can check this running on command line: xcodebuild -list. You will only see target not scheme.

To create it you have to open the iOS project into Xcode IDE. I haven’t found a wat to generate the sheme on command line.

UPDATE: you have to run: “ionic build ios --device” (This will create de IPA) and you can add --release or --debug. With those options it will try to sign the app with Development or Distribution certificates, you MUST have them in your keychain.

Regards