Building Xcode iOS projects and creating *.ipa file from the command line
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的更多相关文章
- 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 ...
- Accept Xcode/iOS License to run git
在没有安装Xcode的情况下, 使用了 webstorm 的git,提示 安装xcode,安装完成后,并没有打开xcode,而是再次使用git,发现 提示 输入以下命令行: sudo xcodebui ...
- 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 ...
- 怎样安装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 ...
- 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 ...
- 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 ...
- Unity3D研究院之IOS全自动打包生成ipa
接着上一篇文章, 自动生成framework,这篇文章我把shell自动化打包ipa整理了一下,希望大家喜欢,嘿嘿.. 建议大家先看一下上一篇文章.http://www.xuanyusong.com/ ...
- 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 移动开发 ...
- Building QT projects from the command line
/************************************************************************ * Building QT projects fro ...
随机推荐
- 将Xml字符串转换成(DataTable || DataSet || XML)对象
今天用到一个功能:就是把从数据库读出来的内容转换成XML字符串流格式,并输出给一个功能函数.在写的过程,为方便以后的使用,我对这一功能进行分装.该类的具体格式如下:XmlConvert类命名空间:Ni ...
- Careercup - Facebook面试题 - 5188884744896512
2014-05-02 07:18 题目链接 原题: boolean isBST(const Node* node) { // return true iff the tree with root 'n ...
- 工程移除CocoaPods依赖库
http://zanderzhang.gitcafe.io/2015/09/26/工程移除CocoaPods依赖库/ 点这里--->CocoaPods安装和使用教程 当我们工程安装很多第三方开源 ...
- 汇编语言中有一种移位指令叫做循环左移(ROL),现在有个简单的任务,就是用字符串模拟这个指令的运算结果。对于一个给定的字符序列S,请你把其循环左移K位后的序列输出。例如,字符序列S=”abcXYZdef”,要求输出循环左移3位后的结果,即“XYZdefabc”。是不是很简单?OK,搞定它!
// test20.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include<iostream> #include< ...
- 给定一个double类型的浮点数base和int类型的整数exponent。求base的exponent次方。
// test14.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include<iostream> #include< ...
- 剑指offer--面试题4
题目:替换字符串中的空格为“%20”. 说明:在浏览器的地址栏中输入某个网址,在解析过程中会看到类似“%20”的字样,这应该就是网络编程涉及的内容... 该题总体来说比较简单(连我都能想到!),个人认 ...
- SSAO
http://blog.csdn.net/xoyojank/article/details/5734537 http://john-chapman-graphics.blogspot.com/2013 ...
- WCF入门(七)——异常处理1
首先以一个简单的例子演示一下远程调用发生异常的结果: 服务器端代码如下: [ServiceContract] public interface IService1 { [OperationContra ...
- javascript 比较
javascript中由于是弱类型,所以在比较的时候有较大的麻烦.这次专门做了总结: Comparison Operators Comparison operators are used in log ...
- hdu 4282 A very hard mathematic problem
由于k的范围是0-2^31,而且x,y,z都是正整数,由题易知道2<=z<31,1<=x<y;所以直接枚举就好了!!! #include<iostream> #in ...