The iPhone Wiki is no longer updated. Visit this article on The Apple Wiki for current information. |
Difference between revisions of "Toolchain 2.0"
(→iPhone/iPod Touch) |
(referring people to iphonedevwiki for newer info) |
||
(11 intermediate revisions by 8 users not shown) | |||
Line 1: | Line 1: | ||
This article explains how to build a tool chain for iPhone OS 2.0. |
This article explains how to build a tool chain for iPhone OS 2.0. |
||
+ | Want a toolchain for developing for a newer version of iOS? See [http://iphonedevwiki.net/index.php/On-device_toolchains "On-device toolchains" on the iPhoneDevWiki]. |
||
− | '''Please note that this section is under development.''' |
||
__TOC__ |
__TOC__ |
||
== Mac OS X == |
== Mac OS X == |
||
+ | Until a valid iPhone ARM toolchain installer can be legally distributed throughout the public (grr NDA), the alternative is simple. Install the Apple iPhone SDK, and use it's compiler, and specify the correct architecture, like so: |
||
− | fill this in. somebody did not get this memo :P |
||
+ | /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc -arch armv6 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.1.sdk |
||
− | toolchain != apple sdk |
||
+ | |||
+ | For extra headers that you have either obtained from an external source, or dumped from the iphone or iphone simulator frameworks yourself, place them in a custom include directory and pass the -I option through the compiler like so: |
||
+ | |||
+ | ..../gcc -I "YOUR INCLUDE DIRECTORY"....... |
||
+ | |||
+ | Use saurik's codesign tool (ldid) to sign the binary like so: |
||
+ | |||
+ | ldid -S <binary> |
||
+ | |||
+ | More on this coming soon. |
||
== Windows XP == |
== Windows XP == |
||
=== Extraction of iPhone OS 2.0 SDK === |
=== Extraction of iPhone OS 2.0 SDK === |
||
+ | ''Please Note: As of 7-Zip 4.59 Beta, support is available for .DMG and XAR-format archives. 7-Zip is now capable of completely extracting iPhone 2.0 SDK Package.'' |
||
* Download the iPhone OS 2.0 SDK from [http://developer.apple.com/iphone/index.action Apple iPhone Dev Center]. |
* Download the iPhone OS 2.0 SDK from [http://developer.apple.com/iphone/index.action Apple iPhone Dev Center]. |
||
* Download and install ''HFSExplorer'' from [http://hem.bredband.net/catacombae/hfsx.html catacombae software]. |
* Download and install ''HFSExplorer'' from [http://hem.bredband.net/catacombae/hfsx.html catacombae software]. |
||
Line 29: | Line 40: | ||
mount -t hfs -o loop /path/to/iphone_sdk_final.dmg /somepath/somedir |
mount -t hfs -o loop /path/to/iphone_sdk_final.dmg /somepath/somedir |
||
:Copy <tt>iPhoneSDKHeadersAndLibs.pkg</tt> from <tt>/somepath/somedir</tt> |
:Copy <tt>iPhoneSDKHeadersAndLibs.pkg</tt> from <tt>/somepath/somedir</tt> |
||
− | * Use the ''eXtensible ARchiver'' <tt>xar</tt> to extract the file <tt>Payload</tt> file containing the actual header files: |
+ | * Use the ''[http://code.google.com/p/xar/ eXtensible ARchiver]'' <tt>xar</tt> to extract the file <tt>Payload</tt> file containing the actual header files: |
xar -xf iPhoneSDKHeadersAndLibs.pkg Payload |
xar -xf iPhoneSDKHeadersAndLibs.pkg Payload |
||
− | * |
+ | *Extract the contents of the resulting <tt>Payload</tt> file |
− | + | zcat Payload | cpio -id |
|
− | * Uncompress the <tt>Payload.gz</tt> file: |
||
− | gunzip Payload.gz |
||
− | * Extract the contents of the resulting <tt>Payload</tt> file: |
||
− | cat Payload | cpio -i |
||
or |
or |
||
− | + | zcat Payload | cpio -id '*.h' |
|
to extract only all header files included in the package. |
to extract only all header files included in the package. |
||
=== Framework Headers === |
=== Framework Headers === |
||
This section assumes that |
This section assumes that |
||
− | + | zcat Payload | cpio -id '*.h' |
|
got used in previous section. |
got used in previous section. |
||
Line 81: | Line 88: | ||
mv SystemConfiguration.framework/Headers include/SystemConfiguration |
mv SystemConfiguration.framework/Headers include/SystemConfiguration |
||
mv UIKit.framework/Headers include/UIKit |
mv UIKit.framework/Headers include/UIKit |
||
+ | rmdir -p *.framework |
||
+ | |||
+ | * The above commands can also be simplified (and can be applied to other versions of SDKs, for example, iPhone SDK 2.2) using a bash shell command: |
||
+ | for a in *.framework; do mv $a/Headers include/${a%.*}; done |
||
rmdir -p *.framework |
rmdir -p *.framework |
||
Line 103: | Line 114: | ||
== iPhone/iPod Touch == |
== iPhone/iPod Touch == |
||
− | There is a tool chain available after jailbreak from the [[Cydia|Cydia installer]]. You just need to install |
+ | There is a tool chain available after jailbreak from the [[Cydia Application|Cydia installer]]. You just need to install |
− | the ''' |
+ | the '''GNU C Compiler''' from Cydia to get the development environment on your iPhone |
− | or iPod Touch. |
+ | or iPod Touch. BigBoss has some comments on this Toolchain on his |
webpage ''[http://thebigboss.org/moreinfo/Toolchain2.php Toolchain 2.0]''. |
webpage ''[http://thebigboss.org/moreinfo/Toolchain2.php Toolchain 2.0]''. |
||
Line 111: | Line 122: | ||
iPhone OS 2.0 SDK as described in section ''[[#Framework Headers|Framework Headers]]''. |
iPhone OS 2.0 SDK as described in section ''[[#Framework Headers|Framework Headers]]''. |
||
− | + | '''NOTE:''' |
|
When using iphone-gcc ( the native compiler ) to compile iPhone applications, you must do one of the following: |
When using iphone-gcc ( the native compiler ) to compile iPhone applications, you must do one of the following: |
||
# Patch the SDK header files for use with the compiler ( stupid thing doesn't like the new headers! ) or |
# Patch the SDK header files for use with the compiler ( stupid thing doesn't like the new headers! ) or |
||
Line 143: | Line 154: | ||
-bind_at_load \ |
-bind_at_load \ |
||
-multiply_defined suppress |
-multiply_defined suppress |
||
+ | |||
+ | If you want to test the iPhone 2.0 Toolchain, you may use this [[HelloWorld on iPhone|HelloWorld]] example. |
||
+ | |||
+ | == Misc. Issues == |
||
+ | |||
+ | For the iPhone 2.2 SDK headers, you might encounter an error about not finding the stdint.h file when compiling natively on the iPhone. In that case, try this: |
||
+ | cd /var/include |
||
+ | ls stdint.h # make sure it doesn't exist |
||
+ | ln -s gcc/darwin/4.0/stdint.h stdint.h |
Latest revision as of 23:46, 7 February 2014
This article explains how to build a tool chain for iPhone OS 2.0.
Want a toolchain for developing for a newer version of iOS? See "On-device toolchains" on the iPhoneDevWiki.
Contents
Mac OS X
Until a valid iPhone ARM toolchain installer can be legally distributed throughout the public (grr NDA), the alternative is simple. Install the Apple iPhone SDK, and use it's compiler, and specify the correct architecture, like so:
/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc -arch armv6 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.1.sdk
For extra headers that you have either obtained from an external source, or dumped from the iphone or iphone simulator frameworks yourself, place them in a custom include directory and pass the -I option through the compiler like so:
..../gcc -I "YOUR INCLUDE DIRECTORY".......
Use saurik's codesign tool (ldid) to sign the binary like so:
ldid -S <binary>
More on this coming soon.
Windows XP
Extraction of iPhone OS 2.0 SDK
Please Note: As of 7-Zip 4.59 Beta, support is available for .DMG and XAR-format archives. 7-Zip is now capable of completely extracting iPhone 2.0 SDK Package.
- Download the iPhone OS 2.0 SDK from Apple iPhone Dev Center.
- Download and install HFSExplorer from catacombae software.
- Start HFSExplorer and choose the menu File→Open UDIF Disk Image (.dmg)...
- Select the iPhone 2.0 SDK disk image iphone_sdk_final.dmg and press Open
- When the tool asks Which partition to read leave it at "Mac_OS_X" (Apple_HFS) and press OK
- Go to Packages and select the package you want to extract, e.g. iPhoneSDKHeadersAndLibs.pkg for the iPhone OS 2.0 header files.
- With right mouse button choose Extract data to extract an installation package.
- Please note that in order to extract this .pkg file on Windows, you must compile xar using Cygwin. Make sure you have libxml2, libxml2-devel, openssl and openssl-devel. You can then follow the instructions below.
Linux
Currently we can only describe how to get the headers from the iPhone OS 2.0 SDK.
Extraction of iPhone OS 2.0 Installation Packages (.pkg)
- Extract iPhoneSDKHeadersAndLibs.pkg from iPhone OS 2.0 SDK:
mount -t hfs -o loop /path/to/iphone_sdk_final.dmg /somepath/somedir
- Copy iPhoneSDKHeadersAndLibs.pkg from /somepath/somedir
- Use the eXtensible ARchiver xar to extract the file Payload file containing the actual header files:
xar -xf iPhoneSDKHeadersAndLibs.pkg Payload
- Extract the contents of the resulting Payload file
zcat Payload | cpio -id
or
zcat Payload | cpio -id '*.h'
to extract only all header files included in the package.
Framework Headers
This section assumes that
zcat Payload | cpio -id '*.h'
got used in previous section.
If you want to move all Framework headers into an include directory continue as follows:
- Remove the project XCode templates since they will not be required anymore:
rm -rf Platforms/iPhoneOS.platform/Developer/Library
- Create your target include directory:
mkdir include
- Get just the System and usr directories from the iPhone Os 2.0 SDK and remove the empty Platforms directory hierarchy:
mv Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.0.sdk/* . rmdir -p Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.0.sdk/
- Move the Framework headers to current directory and clean-up empty directory hierarchy:
mv System/Library/Frameworks/* . rmdir -p System/Library/Frameworks/
- Rename/move all Framework header directories into include directory and cleanup
mv AddressBook.framework/Headers include/AddressBook mv AddressBookUI.framework/Headers include/AddressBookUI mv AudioToolbox.framework/Headers include/AudioToolbox mv AudioUnit.framework/Headers include/AudioUnit mv CFNetwork.framework/Headers include/CFNetwork mv CoreAudio.framework/Headers include/CoreAudio mv CoreFoundation.framework/Headers include/CoreFoundation mv CoreGraphics.framework/Headers include/CoreGraphics mv CoreLocation.framework/Headers include/CoreLocation mv Foundation.framework/Headers include/Foundation mv MediaPlayer.framework/Headers include/MediaPlayer mv OpenAL.framework/Headers include/OpenAL mv OpenGLES.framework/Headers include/OpenGLES mv QuartzCore.framework/Headers include/QuartzCore mv Security.framework/Headers include/Security mv SystemConfiguration.framework/Headers include/SystemConfiguration mv UIKit.framework/Headers include/UIKit rmdir -p *.framework
- The above commands can also be simplified (and can be applied to other versions of SDKs, for example, iPhone SDK 2.2) using a bash shell command:
for a in *.framework; do mv $a/Headers include/${a%.*}; done rmdir -p *.framework
- The remaining directories are include with all Framework headers and usr with all system related headers.
- Move the usr/include headers also into new include directory, remove usr/lib since gcc includes will not be needed (at least not on iPhone toolchain), and clean up:
mv usr/include/* include/ rm -rf usr/lib rmdir -p usr/include/
- You may still remove the Payload file since we don't need it anymore:
rm Payload
- Create a tar file so that you can directly transfer to your iPhone:
tar --group 0 --owner 0 -cvf include.tar include
- You are done.
- Now you may transfer the include.tar to your iPhone (as user root), login to your iPhone via ssh and execute following commands to extract the header files (on your iPhone):
cd /var tar xf /private/var/root/include.tar
iPhone/iPod Touch
There is a tool chain available after jailbreak from the Cydia installer. You just need to install the GNU C Compiler from Cydia to get the development environment on your iPhone or iPod Touch. BigBoss has some comments on this Toolchain on his webpage Toolchain 2.0.
If you want to use the header files from iPhone OS 2.0, you can obtain them from the iPhone OS 2.0 SDK as described in section Framework Headers.
NOTE: When using iphone-gcc ( the native compiler ) to compile iPhone applications, you must do one of the following:
- Patch the SDK header files for use with the compiler ( stupid thing doesn't like the new headers! ) or
- Use the old header files ( which are great, but some things dont work/exist the same anymore! ) or
- Use the following settings in your Makefile to avoid warnings and errors during compilation and linking:
CC=/usr/bin/gcc CFLAGS=-fsigned-char -g -ObjC -fobjc-exceptions \ -Wall -Wundeclared-selector -Wreturn-type -Wnested-externs \ -Wredundant-decls \ -Wbad-function-cast \ -Wchar-subscripts \ -Winline -Wswitch -Wshadow \ -I/var/include \ -I/var/include/gcc/darwin/4.0 \ -D_CTYPE_H_ \ -D_BSD_ARM_SETJMP_H \ -D_UNISTD_H_ CPPFLAGS= LD=$(CC) LDFLAGS=-lobjc \ -F/System/Library/Frameworks \ -framework CoreFoundation \ -framework Foundation \ -framework UIKit \ -framework CoreGraphics \ -L/usr/lib -lc /usr/lib/libgcc_s.1.dylib \ -bind_at_load \ -multiply_defined suppress
If you want to test the iPhone 2.0 Toolchain, you may use this HelloWorld example.
Misc. Issues
For the iPhone 2.2 SDK headers, you might encounter an error about not finding the stdint.h file when compiling natively on the iPhone. In that case, try this:
cd /var/include ls stdint.h # make sure it doesn't exist ln -s gcc/darwin/4.0/stdint.h stdint.h