简体   繁体   English

从linux命令行编译IOS程序

[英]Compile IOS program from linux commandline

我想从linux终端(命令行)编译我的IOS应用程序....是否可以这样做,如果是,那怎么样?

Yes, it's possible. 是的,这是可能的。

At least you need: 至少你需要:

  1. Assembler and Linker: cctools and ld64 from apple opensource. 汇编程序和链接器:来自apple opensource的cctools和ld64。
  2. Compiler: Clang/LLVM 编译器:Clang / LLVM
  3. SDK, include headers and libraries. SDK,包括标头和库。
  4. Utilities: such as ldid codesign tool. 实用程序:例如ldid codesign工具。

Step 1 : The compiler 第1步:编译器

Clang/llvm >= 3.2 is highly recommended and tested. 强烈推荐并测试Clang / llvm> = 3.2。

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,请参考这个链接为你的linux发行版构建一个svn版本。

If your distribution already provides clang/llvm packages,make sure it is 3.2 release or above. 如果您的发行版已经提供了clang / llvm软件包,请确保它是3.2版本或更高版本。 Lower version may work but isn't tested. 较低版本可能有效,但未经过测试。

for Ubuntu 13.04 and later, clang/llvm already provided in repos, please run: 对于Ubuntu 13.04及更高版本,已在回购中提供clang / llvm,请运行:

$sudo apt-get install gcc g++ clang libclang-dev uuid-dev libssl-dev libpng12-dev libicu-dev bison flex libsqlite3-dev

to install some dev packages, other dev packages related to llvm/llvm-dev should be installed automatically. 要安装一些开发包,应自动安装与llvm / llvm-dev相关的其他开发包。

Step 2 : The assembler and linker 第2步:汇编程序和链接程序

The latest cctools-855 and ld64-236.3 had been ported from Apple opensource to linux. 最新的cctools-855和ld64-236.3已从Apple opensource移植到linux。 the porting process is a little bit complicated, also with a lot of codes modified for linux, let's just skip it. 移植过程有点复杂,还有许多针对linux修改的代码,让我们跳过它。

please check out the codes from: 请查看以下代码:

svn checkout http://ios-toolchain-based-on-clang-for-linux.googlecode.com/svn/trunk/cctools-porting

Build it: 建立它:

$ 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

For Ubuntu 13.04, since the clang/llvm 3.2 package use a customized libraries/headers path. 对于Ubuntu 13.04,由于clang / llvm 3.2包使用自定义库/头路径。 please setup CFLAGS and CXXFLAGS first before run configure. 请在运行configure之前先设置CFLAGS和CXXFLAGS。

$export CFLAGS="-I/usr/include/llvm-c-3.2"
$export CXXFLAGS="-I/usr/include/llvm-c-3.2"

Step 3: The iPhoneOS SDK. 第3步:iPhoneOS SDK。

The old iPhone SDK with ARC support extracted from xcode had been provided in Download Sections. 从xcode中提取的带有ARC支持的旧iPhone SDK已在下载部分中提供。 You can directly download it and extract it to /usr/share 您可以直接下载并将其解压缩到/ usr / share

For iOS 4.2: https://ios-toolchain-based-on-clang-for-linux.googlecode.com/files/iPhoneOS4.2.sdk.tar.xz 对于iOS 4.2: https//ios-toolchain-based-on-clang-for-linux.googlecode.com/files/iPhoneOS4.2.sdk.tar.xz

For iOS 5.0: https://ios-toolchain-based-on-clang-for-linux.googlecode.com/files/iPhoneOS5.0.sdk.tar.xz 对于iOS 5.0: https//ios-toolchain-based-on-clang-for-linux.googlecode.com/files/iPhoneOS5.0.sdk.tar.xz

For iOS 6.0: https://ios-toolchain-based-on-clang-for-linux.googlecode.com/files/iPhoneOS6.0.sdk.tar.xz 对于iOS 6.0: https//ios-toolchain-based-on-clang-for-linux.googlecode.com/files/iPhoneOS6.0.sdk.tar.xz

For other iOS versions, You may need follow these steps to get the SDK for your self. 对于其他iOS版本,您可能需要按照以下步骤为自己获取SDK。

Step 4: The utilities 第4步:实用程序

iphonesdk-utils is a utility collection for iOS development, provides below utilities: iphonesdk-utils是一个用于iOS开发的实用程序集合,提供以下实用程序:

NOTE: (Some of them are collected from internet with some modifications.) 注意:(其中一些是从互联网上收集并进行一些修改。)

ldid : codesign tool, with armv7/armv7s support and other changes from orig version. ldid:codesign工具,支持armv7 / armv7s以及orig版本的其他更改。 it will be involked by ld64 after link complete. 链接完成后,它将被ld64所涉及。 ios-clang-wrapper : automatically find SDK and construct proper compilation args. ios-clang-wrapper:自动查找SDK并构造适当的编译参数。 ios-switchsdk : switch sdk when multiple version of SDK exist. ios-switchsdk:存在多个版本的SDK时切换sdk。 ios-pngcrush: png crush/de-crush tool, like Apple's pngcrush. ios-pngcrush:png crush / de-crush工具,就像Apple的pngcrush。 ios-createProject : project templates ios-genLocalization : iOS app localization tool based on clang lexer. ios-createProject:项目模板ios-genLocalization:基于clang lexer的iOS应用程序本地化工具。 ios-plutil : plist compiler/decompiler. ios-plutil:plist编译器/反编译器。 ios-xcbuild : convert xcode project to makefile, build xcode project directly under linux. ios-xcbuild:将xcode项目转换为makefile,直接在linux下构建xcode项目。 Download the source tarball from: https://ios-toolchain-based-on-clang-for-linux.googlecode.com/files/iphonesdk-utils-2.0.tar.gz 从以下网址下载源代码tarball: https//ios-toolchain-based-on-clang-for-linux.googlecode.com/files/iphonesdk-utils-2.0.tar.gz

Build and install it: 构建并安装它:

$./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 您可以在此处找到完整信息 - https://code.google.com/p/ios-toolchain-based-on-clang-for-linux/wiki/HowTo_en

The above solution given by Barjomet is correct incase if its not mavericks, but if it is Maverics then following is the solution: Barjomet给出的上述解决方案是正确的,如果它不是特立独行者,但如果它是Maverics,那么以下是解决方案:

1) Install the appropriate command line tool 2) for building :a)xcodebuild -list -project .xcodeproj b)- xcodebuild -scheme build 1)安装适当的命令行工具2)用于构建:a)xcodebuild -list -project .xcodeproj b) - xcodebuild -scheme build

For detail reference you can refer the following link: 有关详细参考,请参阅以下链接:

https://developer.apple.com/library/ios/technotes/tn2339/_index.html . https://developer.apple.com/library/ios/technotes/tn2339/_index.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM