问题描述
我想从linux终端(命令行)编译我的IOS应用程序....
是否可以这样做,如果是,那么如何?
I want to compile my IOS appication from linux terminal(command line)....Is it possible to do so, if yes, then how?
推荐答案
是的,这是可能的。
至少你需要:
- 汇编程序和链接器:来自apple opensource的cctools和ld64。
- 编译器:Clang / LLVM
- SDK,包括标题和库。
- 实用程序:例如ldid codesign工具。
- Assembler and Linker: cctools and ld64 from apple opensource.
- Compiler: Clang/LLVM
- SDK, include headers and libraries.
- Utilities: such as ldid codesign tool.
步骤1:编译器
强烈推荐并测试Clang / llvm> = 3.2。
Clang/llvm >= 3.2 is highly recommended and tested.
如果你想从头开始构建clang / llvm,请参考这个链接为你的linux发行版构建一个svn版本。
If you want to build clang/llvm from scratch, Please refer to this link to build a svn version for your linux distribution.
如果您的发行版已经提供了clang / llvm包,请确保它是3.2版本或更高版本。较低版本可能有效,但未经过测试。
If your distribution already provides clang/llvm packages,make sure it is 3.2 release or above. Lower version may work but isn't tested.
对于Ubuntu 13.04及更高版本,已在回购中提供clang / llvm,请运行:
for Ubuntu 13.04 and later, clang/llvm already provided in repos, please run:
$sudo apt-get install gcc g++ clang libclang-dev uuid-dev libssl-dev libpng12-dev libicu-dev bison flex libsqlite3-dev
要安装一些开发包,应自动安装与llvm / llvm-dev相关的其他开发包。
to install some dev packages, other dev packages related to llvm/llvm-dev should be installed automatically.
第2步:汇编程序和链接器
最新的cctools-855和ld64-236.3从Apple opensource移植到linux。移植过程有点复杂,还有许多针对linux修改的代码,我们只是跳过它。
The latest cctools-855 and ld64-236.3 had been ported from Apple opensource to linux. the porting process is a little bit complicated, also with a lot of codes modified for linux, let's just skip it.
请查看以下代码:
svn checkout http://ios-toolchain-based-on-clang-for-linux.googlecode.com/svn/trunk/cctools-porting
构建它:
$ sed -i 's/proz -k=20 --no-curses/wget/g' cctools-ld64.sh
$ ./cctools-ld64.sh
$ cd cctools-855-ld64-236.3
$
$ ./configure --target=arm-apple-darwin11 --prefix=/usr
$ make
$ make install
对于Ubuntu 13.04,因为clang / llvm 3.2软件包使用自定义库/标头路径。请在运行configure之前先设置CFLAGS和CXXFLAGS。
For Ubuntu 13.04, since the clang/llvm 3.2 package use a customized libraries/headers path. please setup CFLAGS and CXXFLAGS first before run configure.
$export CFLAGS="-I/usr/include/llvm-c-3.2"
$export CXXFLAGS="-I/usr/include/llvm-c-3.2"
第3步:iPhoneOS SDK。
下载章节中提供了从xcode中提取ARC支持的旧iPhone SDK。您可以直接下载并将其解压缩到/ usr / share
The old iPhone SDK with ARC support extracted from xcode had been provided in Download Sections. You can directly download it and extract it to /usr/share
对于iOS 4.2:
For iOS 4.2: https://ios-toolchain-based-on-clang-for-linux.googlecode.com/files/iPhoneOS4.2.sdk.tar.xz
对于iOS 5.0:
For iOS 5.0: https://ios-toolchain-based-on-clang-for-linux.googlecode.com/files/iPhoneOS5.0.sdk.tar.xz
对于iOS 6.0:
For iOS 6.0: https://ios-toolchain-based-on-clang-for-linux.googlecode.com/files/iPhoneOS6.0.sdk.tar.xz
对于其他iOS版本,您可能需要关注以获取SDK你的自我。
For other iOS versions, You may need follow these steps to get the SDK for your self.
第4步:公用事业
iphonesdk-utils是一个用于iOS开发的实用程序集合,提供以下实用程序:
iphonesdk-utils is a utility collection for iOS development, provides below utilities:
注意:(其中一些是从互联网收集并进行一些修改。)
NOTE: (Some of them are collected from internet with some modifications.)
ldid:codesign工具,支持armv7 / armv7s以及orig版本的其他更改。链接完成后,它将被ld64所取代。
ios-clang-wrapper:自动查找SDK并构造适当的编译参数。
ios-switchsdk:当存在多个版本的SDK时切换sdk。
ios-pngcrush:png crush / de-crush工具,就像Apple的pngcrush。
ios-createProject:项目模板
ios-genLocalization:基于clang lexer的iOS应用程序本地化工具。
ios-plutil:plist编译器/反编译器。
ios-xcbuild:将xcode项目转换为makefile,直接在linux下构建xcode项目。
从以下网址下载源代码tarball:
ldid : codesign tool, with armv7/armv7s support and other changes from orig version. it will be involked by ld64 after link complete.ios-clang-wrapper : automatically find SDK and construct proper compilation args.ios-switchsdk : switch sdk when multiple version of SDK exist.ios-pngcrush: png crush/de-crush tool, like Apple's pngcrush.ios-createProject : project templatesios-genLocalization : iOS app localization tool based on clang lexer.ios-plutil : plist compiler/decompiler.ios-xcbuild : convert xcode project to makefile, build xcode project directly under linux.Download the source tarball from: https://ios-toolchain-based-on-clang-for-linux.googlecode.com/files/iphonesdk-utils-2.0.tar.gz
构建并安装它:
$./configure --prefix=/usr
$make
$make install
Build App
现在您可以简单地构建和安装项目:
Now you can build and install your project simply doing:
$cd ProjectDir
$make
$make install IPHONE_IP=<your own device IP
您可以在此处找到完整信息 -
Complete info you can find here — https://code.google.com/p/ios-toolchain-based-on-clang-for-linux/wiki/HowTo_en
这篇关于从linux命令行编译IOS程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!