Sign in Join
Wiki copytemporary

iPhone headers translator: what changed

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

OldNewLine
1-*(iOS only)*
1+[![Apple iOS new.svg](https://upload.wikimedia.org/wikipedia/commons/thumb/4/48/Apple_iOS_new.svg/60px-Apple_iOS_new.svg.png)](</File:Apple_iOS_new.svg>)
22
3+This article applies to [iOS](</Category:iOS> "Category:iOS") only.
4+
5+See also: [[Multiplatform Programming Guide]]
6+
37## Pascal iPhone header translator
48
59### Author
610
7-Anton e-mail: ast DOT a_s AT mail DOT ru
11+Anton e-mail: ast DOT a_s AT mail DOT ru
812
913### Introduction
1014
11-Because 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.
15+Because 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.
1216
1317### File structure
1418
15-There are several files zip available fro download page:
19+There are several files zip available fro download page:
1620
17-- parser.pas - main program;
18-- htranslator.pas - contains main class that perform translation (indeed it only manage this process);
19-- hscanner.pas - contains "c-header scanner" class;
20-- hparser.pas - contains common c-header parser, that translates c declarations (without helper functions with implementations (bodies));
21-- bparser.pas - extends header parser to handle functions with bodies too;
22-- ocparser.pas - extends parser to handle objective-c declarations;
23-- decltypes.pas - contains class to manage translated types;
24-- declids.pas (since 20120410) - contains class to manage globally declared symbols (constants, variables and functions).
21+ * parser.pas - main program;
22+ * htranslator.pas - contains main class that perform translation (indeed it only manage this process);
23+ * hscanner.pas - contains "c-header scanner" class;
24+ * hparser.pas - contains common c-header parser, that translates c declarations (without helper functions with implementations (bodies));
25+ * bparser.pas - extends header parser to handle functions with bodies too;
26+ * ocparser.pas - extends parser to handle objective-c declarations;
27+ * decltypes.pas - contains class to manage translated types;
28+ * declids.pas (since 20120410) - contains class to manage globally declared symbols (constants, variables and functions).
2529
2630### Features (main goals of project)
2731
28-- do not require any additional (input) files, only iPhone SDK C-headers;
29-- produced Pascal units must not need any manual fixes to be compiled;
30-- translate also implementations of helper functions
32+ * do not require any additional (input) files, only iPhone SDK C-headers;
33+ * produced Pascal units must not need any manual fixes to be compiled;
34+ * translate also implementations of helper functions
3135
3236### Version review
3337
34-- Initial version from 2012-03-19: can translate UIKit and related frameworks.
38+ * Initial version from 2012-03-19: can translate UIKit and related frameworks.
3539
36-
3740Translation process was tested for the following SDKs:
3841
39-
40-
4142**iPhoneSimulator** 3.0, 3.2, 4.0, 4.1, 4.2, 4.3, 5.0;
4243
43-
44-
4544**iPhoneOS** 5.0.
4645
47-
4846Compilation of produced units was tested only for iPhoneSimulator 5.0.
4947
5048Test project can be found on download page (ipt.zip contains Lazarus project, notes about its compilation can be found in next section).
5149
52-- ip_pars20120410: can translate almost all frameworks from SDK 5.0.
50+ * ip_pars20120410: can translate almost all frameworks from SDK 5.0.
5351
54-
5552Some 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.
5653
5754### How to parse
5855
59-To 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).
60-
61-Parser parameters:
56+To 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).
6257
63-1. one of parameter must be sdk="path_to_sdk" (mandatory);
64-2. there can be parameter dest="output_path" (to place Pascal units, if not specified "src" is used);
65-3. all other parameters are regarded as names of frameworks to parse.
58+Parser parameters:
6659
67-Example:
60+ 1. one of parameter must be sdk="path_to_sdk" (mandatory);
61+ 2. there can be parameter dest="output_path" (to place Pascal units, if not specified "src" is used);
62+ 3. all other parameters are regarded as names of frameworks to parse.
6863
69-```text
64+Example:
65+```
7066$ ./parser sdk=/Developer/Platforms/iPhoneSimulator/Developer/SDKs/iPhoneSimulator5.0.sdk UIKit
7167```
7268
73-will 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.
69+will 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.
7470
75-*ip_pars20120410.zip* contains two scripts that can be used to start translation process:
71+_ip_pars20120410.zip_ contains two scripts that can be used to start translation process:
7672
77-1. **start_ios.sh** for iPhoneOS 5.0 SDK;
78-2. **start_sim.sh** for iPhoneSimulator 5.0 SDK.
73+ 1. **start_ios.sh** for iPhoneOS 5.0 SDK;
74+ 2. **start_sim.sh** for iPhoneSimulator 5.0 SDK.
7975
80-Notes:
76+Notes:
8177
82-- Before starting these scripts you will need execute *chmod +x* for them.
83-- These scripts cannot be used for SDKs of different versions because trying to parse missing framework leads to fatal error.
78+ * Before starting these scripts you will need execute _chmod +x_ for them.
79+ * These scripts cannot be used for SDKs of different versions because trying to parse missing framework leads to fatal error.
8480
8581### Testing
8682
87-My 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
83+My 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
8884
8985### Download
9086
9187From here: <http://sourceforge.net/projects/p-tools/files/iPhone%20headers%20translator/>
9288
9389<https://github.com/odisey1245/ip_parse>
9490
9591## See Also
9692
97-- [[iPhone/iPod development]]
93+ * [[iPhone/iPod development]]
9894
9995---
100-*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).*
101-Category: iOS
96+*From the Free Pascal wiki, page "iPhone headers translator", as the Internet Archive kept it on 2025-06-16, last changed on 2015-03-08. 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).*

Back to history