Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compile IOS program from linux commandline

I want to compile my IOS appication from linux terminal(command line).... Is it possible to do so, if yes, then how?

like image 854
saurabh Avatar asked Jan 22 '15 09:01

saurabh


People also ask

Can you program for iOS on Linux?

Being an iOS developer, you know that using Xcode (IDE), you will be able to develop iOS mobile apps. However, Xcode only runs on a Mac computer. Thus, you need different ways to develop iOS applications on Linux. For developing an iOS app on Linux, you need virtualization software.

What is Xcodebuild command?

DESCRIPTION. xcodebuild builds one or more targets contained in an Xcode project, or builds a scheme contained in an Xcode workspace or Xcode project. Usage To build an Xcode project, run xcodebuild from the directory containing your project (i.e. the directory containing the projectname. xcodeproj package).

How do I run Xcode from command line app?

go to the 'Info' tab and in a menu 'Executable' choose 'Other...' in file window go to search input field and type 'terminal' and click on its icon when you find it. Now you should see 'Terminal. app' in 'Executable' field.

How do I run Xcode on Mac terminal?

Installing Xcode Command Line Tools To install Xcode Command Line Tools, navigate to your device's Terminal app again through Spotlight Search. Then, type “xcode-select –install” into your terminal and hit Enter.


1 Answers

Yes, it's possible.

At least you need:

  1. Assembler and Linker: cctools and ld64 from apple opensource.
  2. Compiler: Clang/LLVM
  3. SDK, include headers and libraries.
  4. Utilities: such as ldid codesign tool.

Step 1 : The compiler

Clang/llvm >= 3.2 is highly recommended and tested.

If you want to build clang/llvm from scratch, Please refer to this link to build a svn version for your linux distribution.

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.

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

to install some dev packages, other dev packages related to llvm/llvm-dev should be installed automatically.

Step 2 : The assembler and linker

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.

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. 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"

Step 3: The iPhoneOS SDK.

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

For 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

For 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.

Step 4: The utilities

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 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 templates ios-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

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

like image 99
barjomet Avatar answered Oct 23 '22 02:10

barjomet