Skip to content

Building the iOS toolchain for Fedora

lkundrak edited this page Oct 28, 2011 · 4 revisions

What is this good for

The iOS toolchain for Fedora enables you to build native applications for iPhone, iPod Touch and iPad without the need for Mac OS X installation or XCode. This is roughly equivalent to iOS 4.3 SDK release.

The toolchain is made from the open source code made available by Apple and pieces of binary SDK (symbol files and headers) they distribute. The source code needs modifications in order to be buildable and usable on platforms different than Darwin (which is the foundation for Mac OS X), we track those changes here in GIT repositories. Also, the Apple SDK probably (IANAL, interfact (API and ABI) descriptions as such probably would be distributable, if someone made sure the SDK contains nothing else) is not distributable and thus you have to build it yourself.

This repository contains the scripts that apply the required changes to the source code and builds nice RPM packages isolated environment that can be installed and even distributed to other systems. This is unlike other such scripts and guides around the net, which merely do the build and install stuff in place. On the other hand, if your distribution is not based on Fedora (RHEL, CentOS or Scientific Linux are fine, Ubuntu or Debian is not), you are out of luck. Yet you can still use this as a starting point.

What will you need

  • Official Apple SDK

  • mock package installed, to build RPMs in isolated environment

  • dmg2img and kernel with hfsplus support to unpack the Apple SDK bundle

    Alternatively, you may unpack the bundle on a Apple Mac computer.

  • Internet connection, to download the source artifacts

  • iDevice with SSH access (not strictly needed -- just to try the application out)

    If you don't know how to enable SSH access to your device, google for "Jailbreak iPhone."

  • libimobiledevice package that contains useful tools

  • rhythmbox if you need to activate your device first

Extracting the pkg files

You can skip this if you're going to unpack the SDK on an Apple Mac computer.

Download the xcode_3.2.6_and_ios_sdk_4.3.dmg file from Apple Developer web site. Use dmg2img to uncompress it and mount the data partition (you need hfsplus support in your kernel, which is the case for Fedora, but not RHEL):

$ dmg2img xcode_3.2.6_and_ios_sdk_4.3.dmg
$ mount -t hfsplus -o loop xcode_4.2_and_ios_5_sdk_for_snow_leopard.img /mnt
$

Now, get MacOSX10.6.pkg and iPhoneSDK4_3.pkg from /mnt/Packages directory.

Building the toolchain

  • Add yourself to the mock group and log off to start a new session (do this as root)

    $ su -c "usermod -a -G mock $LOGNAME"
    $
  • Clone the toolchain build scripts and change into its directory (do this unprivileged)

    $ git clone git://github.com/rotten-apples/toolchain.git
    $ cd toolchain
    $
  • Put the following *.pkg files into the toolchain directory

    See "Extracting the pkg files" above.

  • Trigger the build

    $ sh buildit.sh
    $

    If you are a missing a tool the script needs, it will complain. Follow the suggestions.

Installing the toolchain

If everything went well, the result will be in resultdir directory underneath toolchain. When in doubt what to install, install everything but source and debugging information:

$ su -c 'ls resultdir/*.rpm |egrep -v "src.rpm|debuginfo" |xargs yum -y --nogpgcheck localinstall'
$

Testing the toolchain

  • Check out the example source

    We're not using XCode or the Interface Builder, so you may serve as an example on how to do without those tools.

    $ git clone git://github.com/rotten-apples/HelloWorld.app.git
    $ cd HelloWorld.app
    $
  • Try to build it!

    $ make
    $
  • Install it to the device

    This requires SSH access and keys set up for both mobile and root users, or it will keep asking for password.

    $ make deploy TARGET=yourdevice.local
    $

    You can now run it. See a screenshot of iPhone version.

What next

Learn Objective-C. It is quite horrible and takes some time to get right. GNUStep's free documentation and code will make that easier even without an iDevice.

If things go bad, easiest way to get debug traces is to hook up the device on USB and launch idevicesyslog tool, though the on-device syslog can be made to log into a file or remote server too. Once you are able to read the log, you can insert NSLog(@"Message") or NSLog(@"%@", object) calls into your code to write messages into the log.

Share your code! GitHub is a good place to upload it for others to see.

Share your thoughts about the tool chain in our issue tracker, here on GitHub.

Have fun.

Credits

Who made this possible

Apple by releasing the source
saurik made an iOS toolchain and provided native packages for Darwin/arm
toolwhip project made a Darwin cross-toolchain
...and numerous hackers around the internets