Building Xcode IOS Projects and creating *.ipa file from the command line

Source: Internet
Author: User

For our development process of IOS applications, we is using the Jenkins set up on the Mac Mini Server, acting as a Continuou s integration (CI) server. It's fairly easy to configure Jenkins for Xcode projects using Xcode plugin-however, from time to time we had some issue s with setting it up correctly. In order to debug them, we ' ve decided to include small shell scripts, this build our iPhone and IPad apps–to compare ResU LTS between our development machines and CI environment.

With introduction of the Xcode 6, building apps from command line became more important for us. For some reason, Xcode 6 requires signing to the Apple Developer account while exporting IOS binaries (*.ipa files). It means that you can no longer export binaries from the Xcode have just provisioning profile and matching certificate, Or do that without Internet connection. However, you can do it easily with command line tools!

If needed, you can find some more information about building the Xcode projects from command line to man pages (Mans Xcodeb Uild) or on Building from the "Command line" with the Xcode FAQ page from the Apple resources.

Installing command line tools

First of all, install the Xcode command line tool if you haven ' t do that yet. Just Follow steps from excellent tutorial on osxdaily, or Just open your favourite terminal app and type:

Xcode-select--install

This command should open POPs Up–just click on the ' Install ' button to continue.

Building Xcode Projects (*.xcodeproj file) from the command line

Let's assume you had project named Bestappever, freshly created with recent version of the Xcode. Navigate to the directory where *.xcodeproj file was located and, as a first step, let's create *.xcarchive file:

Xcodebuild-scheme bestappever Clean Archive-archivepath build/bestappever

By default, Xcodebuild'll choose *.xcdoeproj Project form current directory. However, must specify scheme–if you haven ' t changed anything, it would have same name as a project has. That's -scheme bestappever part. Next, we specify what should is Done–here we first clean up with clean action, and then archive project–specified by -archivepath build/bestappever part.

Next step–create *.ipa File:

Xcodebuild-exportarchive-exportformat Ipa-archivepath "build/bestappever.xcarchive"-exportPath "build/ Bestappever.ipa "-exportprovisioningprofile" Provisioningprofilename "

Here we specify and we want to export the *.ipa file (-exportarchive-exportformat IPA does this job), From the archive we created in previous step (-archivepath "build/bestappever.xcarchive") to a file in Build sub-directory (-exportpath "Build/bestappever.ipa"), with a selected provisioning profiles (-E Xportprovisioningprofile "Provisioningprofilename").

I ' m often wrapping this commands in a handy build.sh shell script:

#!/bin/shxcodebuild-scheme bestappever Clean Archive-archivepath build/bestappeverxcodebuild-exportarchive- ExportFormat Ipa-archivepath "build/bestappever.xcarchive"-exportpath "Build/bestappever.ipa"- Exportprovisioningprofile "Provisioningprofilename"
Building Xcode Workspaces (*.xcworkspace file) from the command line

Of course, most of our projects nowdays is using dependencies managed via Cocoapods tool. It means that we should specify which workspace we want to use during creation of a archive file–to do, add- W Orkspace bestappever.xcworkspace Switch to the first command. Our build.sh script would then has the following content:

#!/bin/shxcodebuild-scheme bestappever-workspace bestappever.xcworkspace Clean Archive-archivepath build/ Bestappeverxcodebuild-exportarchive-exportformat Ipa-archivepath "build/bestappever.xcarchive"-exportPath "build/ Bestappever.ipa "-exportprovisioningprofile" Provisioningprofilename "

I ' m often adding pod install just above first xcodebuild command.

BTW, this post is inspired by the response I ' ve got on StackOverflow for quoestion "make Ad-hoc builds in Xcode 6 without Signing in to developer account ".

Building Xcode IOS Projects and creating *.ipa file from the command line

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.