FPC now supports an Objective-C compatible dialect appropriately titled Objective Pascal. Visit ObjectivePascal.com which is the new home page for the language.
The most recent information on installing compilers for both Cocoa and iOS development can found on the Free Pascal Objective Pascal wiki.
There is also a Mac installer application which will build the most recent version of the compiler for Cocoa development after following a few steps.
Version 1.0.2 (7/16/10): - The installer now accepts a base version (instead of being fixed at 2.2.4) so you can change this manually when new versions of FPC are released. - There is a "Copy Headers" option which will copy the translated headers from SVN to the Objective Pascal directory you specified. - Universal Binary (OS 10.5 and higher). Version 1.0.1: - Widened status label. - Added -p to the cp command when copying files to the ObjectivePascal directory.
PascalGladiator Examples
- CircleView. Pascal port of Apple's CircleView example by Ryan Joseph. Shows how to use the components of the Cocoa text system to draw a custom NSView.
- OutlineView. Pascal port of Apple's OutlineView example by Ryan Joseph. Shows the most basic implementation of NSOutlineView using the file system as a data source.
- MiniBrowser. Pascal port of Apple's MiniBrowser WebKit API example by Ryan Joseph. This requires at least revision 13831 of WebKit headers from SVN.
- NIBWindows. This was an example project I made but corrected by Gorazd Krosl to more Cocoa-ish. ;)
- PLuaTerminal. Simple terminal for the lua programming language by Gorazd Krosl.
- TemperatureConverter. Pascal version of the Apple Cocoa tutorial application for beginners by Gorazd Krosl.
- FPCEventManager. Simple CoreData document based application, a port of Apple's EventManager by Gorazd Krosl.
TextMate Examples
Same as the examples for PascalGladiator but ported to TextMate project format (requires the Pascal TextMate bundle).
Xcode Examples
- Pascal Cocoa Templates. Xcode project templates by Gorazd Krosl that can be installed into Xcode. There is a read me file included with instructions on how to install and compile the projects.
- TemperatureConverter. Pascal version of the Apple Cocoa tutorial application for beginners by Gorazd Krosl.
Library Examples
- RegexKitLite. Pascal port of RegexKitLite by Gorazd Krosl. A framework is supplied for linking which must be placed inside the applications bundle in the Frameworks folder. The example contains only a single unit which is the complete interface to the framework.
iPhone Examples
These examples require the iPhone SDK (from Apple) and translated Pascal interfaces to run (which I can not distribute, see the script above). As of version 0.7.2 PascalGladiator supports a target for compiling bundles which will run in the iPhone simulator but Xcode and certificate ($99) is still required for device targets.
- iArkanoid. This is a test game by Dmitry 'skalogryz' Boyarintsev which shows how to make a basic iPhone app using CoreGraphics.
- HelloWorldPascaliPhone. Pascal version of Apple's "Hello World" example (in Xcode project) by Scott Knapp.
The most current Cocoa headers (parsed from their respective Cocoa frameworks) which compile with the latest version of the compiler can be download from the FPC SVN repository here.
Because it against Apples user agreement to distribute iOS headers in translated form they must be parsed manually. There is always a parser script (which invokes the framework parser and patches any errors) in the FPC source distribution downloaded from SVN. To learn how use the script visit the Objective Pascal Wiki.
Applications compiled outside of Xcode can be submitted to the Mac App Store after following these steps and running the installation script. Before continuing to compile anything read the Apple submission checklist and prepare your account and other details.
Requirements for the script:
- Download the Application Tools package from Apples website or Xcode 3.2.5 which includes the tools as you will need Application Loader to submit the binary. You must be a registered Apple developer and pay an annual $99 fee before you can submit to the Mac App Store.
- You must have created 2 certificates using the Developer Certificate Utility. You will need to create both the Application and Installer certificates which will be presented as options if you are a registered developer.
Requirements for compiling and building:
- First read the official Apple submission guidelines and be sure to comply with all points.
- Compile the final binary to submit with:
-gw -godwarfsets -Xg -O2
. - Universal or PPC binaries are not accepted so you must compile all binaries using only
ppc386
. - Any helper apps inside the main bundle should be Intel only binaries, reside in
/Contents/Library/LoginItems
and be compiled with optimization using-O2
.
Script usage
-path: Path to the application bundle. -sign: Developer signature for code signing which starts with "3rd Party Mac Developer Application:" (this can be found in Keychain Access under My Certificates). Do NOT include the aforementioned prefix only text following the colon without preceding spaces. -install: The install path of the .pkg file (defaults to /Applications which is required by Apple). -dsym: Path to a debugging .dSYM file (for example /path/to/Main.dSYM). -launch: The Application Loader will be launched upon completion of the script. -password: Password to the currently logged in OS X user for testing the package installation. If no password is provided the verification process will be skipped.
Download the script here. The script is written in PHP so to execute in the terminal use the command php appstore.php. If you run the script with no parameters the usage will be displayed along with other instructions.
The first step to developing for iOS is building the ARM and iOS simulator compilers. The most recent information on this process can found on the Free Pascal Objective Pascal wiki. Before continuing make sure you have installed the compilers successfully.
Once you have compiled a binary you need to install the application to the device via Xcode. This step requires you register with the iPhone developer program and pay an annual fee of $99. After you registration is accepted (this will take a few days) you will be able to create a certificate via the developer web site (Provisioning Portal) which you will download and install into Xcode. This is a rather long process actually and involves many steps but the site will walk you through all of them. Finally after the certificate has been installed successfully in Xcode, running iPhone projects with a device target will install the application onto said device.
This multi-step process is automated (you never need to use Xcode manually once configured) with a script found here. To run the script use a command like: php install_iphone_app.php -binary="path/to/binary" -project="path/to/iphone_template" -config="Debug" -dev="John Doe (SDJKLD9D8S9)"
which will build the Xcode project, copy the FPC binary, code sign the binary and resources then run the project from Xcode via AppleScript thus installing the application.
Requirements
- Create an Xcode iPhone project. In Xcode create a new project using any iPhone template then delete all source files and resources (besides main.m). Copy any resources and info.plist files into the Xcode project as they will be copied into the application bundle when it is built (you can also copy files directly into the application bundle). Make sure you select Debug as the active configuration and any SDK "device" named SDK for active SDK.
- Get the iPhone developer string. Build the project and then inspect the Build Results window. In the code sign item copy the text after iPhone Developer: (see the screen shot for help). This string will be used as the -dev option (see below).
Script usage
-config: Active configuration in Xcode project (Debug or Release). -binary: Path to ARM binary compiled with FPC. -project: Path to Xcode iPhone project. -dev: iPhone Developer as in the Xcode code sign command. Example: John Doe (DKJF87DHSJKD).