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 ...
随机推荐
- 查看Linux磁盘空间大小
一.df 命令: df 是来自于coreutils 软件包,系统安装时,就自带的:我们通过这个命令可以查看磁盘的使用情况以及文件系统被挂载的位置: 举例: [root@localhost beinan ...
- MYSQL-实现ORACLE- row_number() over(partition by ) 分组排序功能
MYSQL-实现ORACLE- row_number() over(partition by ) 分组排序功能 由于MYSQL没有提供类似ORACLE中OVER()这样丰富的分析函数. 所以在MYSQ ...
- angular入门系列教程1
主题: 一个能够跑起来的页面,神奇的效果,无需一样JS代码! 效果图: 细节: 当然,这里甚至连登陆都没做,只是看到神奇的当输入用户名或者密码的时候,下面的预览区域也会有相应的更改.没有一行的JS代码 ...
- 完整实例(C# Socket)
问题描述: 现在创建一个C# Socket实例,客户端断开服务器能立刻输出断开连接客户端信息 服务器端断开,客户端能立刻察觉服务器状态 问题解决: 服务器端代码: 客户端代码: 以上 ...
- MongoDB { code: 18, ok: 0.0, errmsg: "auth fails" } 原因
MongoDB出现 { code: 18, ok: 0.0, errmsg: "auth fails" } 错误的原因: 1.账号密码错误 2.账号不属于该数据库
- Finite State Machine
Contents [hide] 1 Description 2 Components 3 C# - FSMSystem.cs 4 Example Description This is a Dete ...
- linux网卡速率和双工模式的配置
linux网卡速率和双工模式的配置 (2012-09-06 14:39:57) 转载▼ 标签: 科技 网络接口 协商 网卡 工具 it 分类: Linux 改变网络接口的速度和协商方式的工具miito ...
- [shell编程]正则表达式
如果在shell脚本中处理数据文件,那么我们就必须熟悉正则表达式.正则表达式是用来过滤数据流中文本的模式模板,模式由标准文本字符和特殊字符组成.正则表达式用特殊字符来匹配一系列一个或多个字符,要想掌握 ...
- 在实体注解OneToMany时,要加上mappedby,避免产生中间表。
在实体注解OneToMany时,要加上mappedby,避免产生中间表.
- APT攻击
http://netsecurity.51cto.com/art/201211/363040.htm