Sign in Join
Wiki copytemporary

iPhone headers translator: what changed

Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
11*(iOS only)*
22
33## Pascal iPhone header translator
44
55### Author
66
77Anton e-mail: ast DOT a_s AT mail DOT ru
88
99### Introduction
1010
1111Because no one can redistribute Pascal units for iOS SDK we need a tool that can produce such units from official C headers. Of course everyone can take original headers and manually translate them but it is not the simplest work. Indeed this process can be (at least partially) automated. I'd like to present iPhone headers translator that is written in FPC.
1212
1313### File structure
1414
1515There are several files zip available fro download page:
1616
1717- parser.pas - main program;
1818- htranslator.pas - contains main class that perform translation (indeed it only manage this process);
1919- hscanner.pas - contains "c-header scanner" class;
2020- hparser.pas - contains common c-header parser, that translates c declarations (without helper functions with implementations (bodies));
2121- bparser.pas - extends header parser to handle functions with bodies too;
2222- ocparser.pas - extends parser to handle objective-c declarations;
2323- decltypes.pas - contains class to manage translated types;
2424- declids.pas (since 20120410) - contains class to manage globally declared symbols (constants, variables and functions).
2525
2626### Features (main goals of project)
2727
2828- do not require any additional (input) files, only iPhone SDK C-headers;
2929- produced Pascal units must not need any manual fixes to be compiled;
3030- translate also implementations of helper functions
3131
3232### Version review
3333
3434- Initial version from 2012-03-19: can translate UIKit and related frameworks.
3535
3636
3737Translation process was tested for the following SDKs:
3838
3939
4040
4141**iPhoneSimulator** 3.0, 3.2, 4.0, 4.1, 4.2, 4.3, 5.0;
4242
4343
4444
4545**iPhoneOS** 5.0.
4646
4747
4848Compilation of produced units was tested only for iPhoneSimulator 5.0.
4949
5050Test project can be found on download page (ipt.zip contains Lazarus project, notes about its compilation can be found in next section).
5151
5252- ip_pars20120410: can translate almost all frameworks from SDK 5.0.
5353
5454
5555Some frameworks (applicationservices, coreservices, accelerate, carbon) for now are translated to empty units because translation of "nested frameworks" is not implemented yet. Parsing process was tested for iPhoneSimulator 5.0 and iPhoneOS 5.0, compilation was tested only for simulator.
5656
5757### How to parse
5858
5959To build parser "fpc parser" is enough. Of course you need to install iPhone SDK. Cause I have only simulator, I will use its SDK. Typically it is installed to /Developer/Platforms/iPhoneSimulator/Developer/SDKs/iPhoneSimulator5.0.sdk (for 5.0 version). The path to SDK will be used as a parameter of parser. Indeed, it's time to start it. Parser contains a little help, so it can be used (--help or without parameters).
6060
6161Parser parameters:
6262
63631. one of parameter must be sdk="path_to_sdk" (mandatory);
64642. there can be parameter dest="output_path" (to place Pascal units, if not specified "src" is used);
65653. all other parameters are regarded as names of frameworks to parse.
6666
6767Example:
6868
69-`$ ./parser sdk=/Developer/Platforms/iPhoneSimulator/Developer/SDKs/iPhoneSimulator5.0.sdk UIKit`
69+```text
70+$ ./parser sdk=/Developer/Platforms/iPhoneSimulator/Developer/SDKs/iPhoneSimulator5.0.sdk UIKit
71+```
7072
7173will translate UIKit and all dependant frameworks (cfnetwork, corefoundation, coregraphics, coreimage, corevideo, foundation, opengles, security). I've tested it for SDKs 3.0, 3.2, 4.0, 4.1, 4.2, 4.3, 5.0. Although now it works good there are some "todo's" and unimplemented parts.
7274
7375*ip_pars20120410.zip* contains two scripts that can be used to start translation process:
7476
75771. **start_ios.sh** for iPhoneOS 5.0 SDK;
76782. **start_sim.sh** for iPhoneSimulator 5.0 SDK.
7779
7880Notes:
7981
8082- Before starting these scripts you will need execute *chmod +x* for them.
8183- These scripts cannot be used for SDKs of different versions because trying to parse missing framework leads to fatal error.
8284
8385### Testing
8486
8587My test program is also attached (*ipt.zip* contains Lazarus project). Project output directory must be changed. In order to run it in Simulator I have created empty XCode project "iphone_test" and run it. After that I've closed XCode and run only simulator - it has contained my new program "iphone_test". After that I've simply replaced binary /Users/macuser/Library/Application Support/iPhone Simulator/5.0/Applications/C93F7A57-E612-4A40-B155-DB106CA860D6/iphone_test.app/iphone_test
8688
8789### Download
8890
8991From here: <http://sourceforge.net/projects/p-tools/files/iPhone%20headers%20translator/>
9092
9193<https://github.com/odisey1245/ip_parse>
9294
9395## See Also
9496
9597- [[iPhone/iPod development]]
9698
9799---
98100*From the Free Pascal wiki, page "iPhone headers translator", as it stood on 2015-03-07 after a change by Penilopa P, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*
99101Category: iOS

Back to history