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 Organizer, go to "Archived Applications," and "Submit Application to iTunesConnect."
Is there a way to use "Build and Archive" from the command line (as part of a build script)? I'd assume that xcodebuild
would be involved somehow, but the man
page doesn't seem to say anything about this.
UPDATE Michael Grinich requested clarification; here's what exactly you can't do with command-line builds, features you can ONLY do with Xcode's Organizer after you "Build and Archive."
- You can click "Share Application..." to share your IPA with beta testers. As Guillaume points out below, due to some Xcode magic, this IPA file does not require a separately distributed .mobileprovision file that beta testers need to install; that's magical. No command-line script can do it. For example, Arrix's script (submitted May 1) does not meet that requirement.
- More importantly, after you've beta tested a build, you can click "Submit Application to iTunes Connect" to submit that EXACT same build to Apple, the very binary you tested, without rebuilding it. That's impossible from the command line, because signing the app is part of the build process; you can sign bits for Ad Hoc beta testing OR you can sign them for submission to the App Store, but not both. No IPA built on the command-line can be beta tested on phones and then submitted directly to Apple.
I'd love for someone to come along and prove me wrong: both of these features work great in the Xcode GUI and cannot be replicated from the command line.
Go to the folder where's your project root and:
try xctool, it is a replacement for Apple's xcodebuild that makes it easier to build and test iOS and Mac products. It's especially helpful for continuous integration. It has a few extra features:
No.3 is extremely useful. I don't if anyone can read the console output of xcodebuild, I can't, usually it gave me one line with 5000+ characters. Even harder to read than a thesis paper.
xctool: https://github.com/facebook/xctool
if you use next tool: https://github.com/nomad/shenzhen
then this task is very easy:
source
I have given a brief description of steps to follow, and parameters to pass while generating an ipa using terrminal below:
Go to the folder which contains the MyApp.xcodeproject file in terminal
By using the command given below you will get all the Targets of the application
After the above command is executed, you will get a list of targets of which you should select a specific target you need to generate .ipa
The above command builds the project and creates a .app file.The path to locate the .app file is
./build/Release-iphoneos/MyApp.app
After Build gets succeeded then execute the following command to generate .ipa of the application using Developer Name and Provisioning Profile using the syntax below:
Explanation of each Parameter in the above syntax:
Archive
IPA Export (please note the export option plist)
For those who don't know about exportOptions.plist, https://blog.bitrise.io/new-export-options-plist-in-xcode-9
Those who were using this for building project in CI/CD tools like teamcity/jenkins, please make sure you are using the right xcode installed in the build agent for for both archive and export.
You can use either of below 2 options for this.
/Applications/Xcode 9.3.1.app/Contents/Developer/usr/bin/xcodebuild
xcode-select -switch /Applications/Xcode 9.3.1.app
Here is command line script for creating archive and IPA example. I have an iPhone xcode project , which is located in Desktop/MyiOSApp folder.
Execute following commands one by one .
This is tested with Xcode 5 and working fine for me.
Improving on Vincent's answer, I wrote a script to do that:
xcodearchive
It allows you to archive (generate an ipa) your project via the command line. Think of it like the sister of the
xcodebuild
command, but for archiving.Code is available on github: http://github.com/gcerquant/xcodearchive
One option of the script is to enable the archiving of the dSYM symbols in a timestamped archive. No excuse to not keep the symbols anymore, and not be able to symbolicate the crash log you might later receive.