For our development process of iOS applications, we are using Jenkins set up on the Mac Mini Server, acting as a Continuous Integration (CI) server. It’s fairly easy to configure Jenkins for Xcode projects using Xcode Plugin - however, from time to time we had some issues with setting it up correctly. In order to debug them, we’ve decided to include small shell scripts that build our iPhone and iPad apps – to compare results 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 into the Apple Developer account while exporting iOS binaries (*.ipa files). It means that you can no longer export binaries from the Xcode having 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 on man pages (man xcodebuild) or on Building from the Command Line with Xcode FAQ page from the Apple resources.

Installing command line tools

First of all, install Xcode command line tool if you haven’t done 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 pop up – just click on ‘Install’ button to continue.

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

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

xcodebuild -scheme BestAppEver clean archive -archivePath build/BestAppEver

By default, xcodebuild will choose *.xcdoeproj project form current directory. However, you must specify scheme – if you haven’t changed anything, it will have same name as a project has. That’s -scheme BestAppEver part. Next, we specify what should be 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 that 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 profile (-exportProvisioningProfile “ProvisioningProfileName”).

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

#!/bin/sh
xcodebuild -scheme BestAppEver clean archive -archivePath build/BestAppEver
xcodebuild -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 are using dependencies managed via cocoapods tool. It means that we should specify which workspace we want to use during creation of an archive file – to do that, add -workspace BestAppEver.xcworkspace switch to the first command. Our build.sh script would then have following content:

#!/bin/sh
xcodebuild -scheme BestAppEver -workspace BestAppEver.xcworkspace clean archive -archivePath build/BestAppEver
xcodebuild -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 was inspired by the response I’ve got on StackOverflowfor 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的更多相关文章

  1. how to import a SQL file in MySQL command line

    how to import a SQL file in MySQL command line execute .sql file, macOS $mysql> source \home\user ...

  2. Accept Xcode/iOS License to run git

    在没有安装Xcode的情况下, 使用了 webstorm 的git,提示 安装xcode,安装完成后,并没有打开xcode,而是再次使用git,发现 提示 输入以下命令行: sudo xcodebui ...

  3. How to build .apk file from command line(转)

    How to build .apk file from command line Created on Wednesday, 29 June 2011 14:32 If you don’t want ...

  4. 怎样安装Command Line Tools in OS x Mavericks&Yosemite(Without xcode)--转载

    How to Install Command Line Tools in OS X Mavericks & Yosemite (Without Xcode) Mac users who pre ...

  5. Yandex Big Data Essentials Week1 Unix Command Line Interface File Content exploration

    cat displays the contents of a file at the command line copies or apppend text file into a document ...

  6. NewRelicAgent(CustomAnalyticEvent.cxx.o), building for iOS simulator, but linking in object file built for OSX, for architecture x8(botched)

    昨天遇到一个问题,在项目swift1.2适配swift2.0的过程中,修改完毕之后,运行报错如下: /Pods/NewRelicAgent/NewRelic_iOS_Agent_5.1.0/NewRe ...

  7. Unity3D研究院之IOS全自动打包生成ipa

    接着上一篇文章, 自动生成framework,这篇文章我把shell自动化打包ipa整理了一下,希望大家喜欢,嘿嘿.. 建议大家先看一下上一篇文章.http://www.xuanyusong.com/ ...

  8. Xcode 4-PBXcp error修复-No such file or directory

    Xcode 4-PBXcp error修复-No such file or directory (2013-05-02 15:20:50) 转载▼ 标签: apple iphone ios 移动开发 ...

  9. Building QT projects from the command line

    /************************************************************************ * Building QT projects fro ...

随机推荐

  1. Halcon学习笔记之缺陷检测(一)

    例程:surface_scratch.hdev 说明:这个程序利用局部阈值和形态学处理提取表面划痕 代码中绿色部分为个人理解和注释,其余为例程中原有代码 *surface_scratch.hdev:e ...

  2. 文件中的类都不能进行设计,因此未能为该文件显示设计器。设计器检查出文件中有以下类: FormMain --- 未能加载基类“WinForm.Win.FormsBase.FormMainBase”。请确保已引用该程序集并已生成所有项目

    出现该问题的原因:FormMain从FormMainBase继承之后,一旦修改FormMainBase就会出现这个问题 解决方案:(1-4是搜索网友的) 1: 关闭VS所有窗口,后重启.即可返回正常. ...

  3. php中的性能挖掘

    搞php以后,感觉总是很别扭,因为我觉得php会很慢,因为array普遍,在Key的循环查找不是很浪费性能么!因为我以前搞.net和java,他们是用的大多是寻址和索引方式,而php中太多是使用Key ...

  4. C#快速排序算法基础入门篇

    相信算法对于许多开发人员来说都是一大难点,之所以难,就像设计模式一样,许多人在阅读之后,没有很好地理解,也不愿意动手上机操作,只停留在理论的学习上面,随着时间推移就慢慢淡忘. 有些东西,你可以发明创造 ...

  5. 【递推】BZOJ 1088: [SCOI2005]扫雷Mine

    1088: [SCOI2005]扫雷Mine Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 2275  Solved: 1328[Submit][St ...

  6. ios开发之网络访问的数据类型

    1> JSON 特点:1. [ ] 表示数组  {} 表示字典 - 对象模型建立关系 2. 应用非常多,基本上移动开发的主要数据传输都是JSON 要使用JSON,从网络上获取到数据data后,直 ...

  7. 基于 Eclipse 平台的代码生成技术

    ------------------------------------------------------------------ 转自http://www.ibm.com/developerwor ...

  8. linux配置mysql,tomcat命令vi

    [root@yangchehome bin]# ./mysqld_safe -user=mysql & [1] 17135 [root@yangchehome bin]# 140316 16: ...

  9. HDU2594 Simpsons’ Hidden Talents 字符串哈希

    最近在学习字符串的知识,在字符串上我跟大一的时候是没什么区别的,所以恶补了很多基础的算法,今天补了一下字符串哈希,看的是大一新生的课件学的,以前觉得字符串哈希无非就是跟普通的哈希没什么区别,倒也没觉得 ...

  10. java集合--java.util.ConcurrentModificationException异常

    ConcurrentModificationException 异常:并发修改异常,当方法检测到对象的并发修改,但不允许这种修改时,抛出此异常.一个线程对collection集合迭代,另一个线程对Co ...